Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the instruction set in Figure 6.5 translate the following algorithmic prim

ID: 3912185 • Letter: U

Question

Using the instruction set in Figure 6.5 translate the following algorithmic primitives into assembly language code. Show all necessary .DATA pseudo-ops.

1. Add 5 to the value of X

2. Subtract 8 from the value of Y

FIGURE 6.5 FIGURE 6.13 Binary Op Code Operation LOAD X STORE X CLEARX ADD X INCREMENT X SUBTRACT X DECREMENT X COMPAREX Instruction Format: Op Code 4 bits Address 12 bits Meaning R ? CON(X) 0-CONÇX Object Program: 0010 Machine Language Instruction 1101 000000001001 1101 000000001010 0000 000000001001 0111 000000001010 1001 000000000111 1110 000000001001 1000 1110 000000001010 ess Meaning 0100 0101 0110 0111 CON(X) + 1 ? CON(X) 0010 LOAD X COMPARE Y JUMPGT DONE OUTX JUMP LOOP OUT Y CON(X)-1-CONCX) if CONCX)> R then GT 1 else 0 if CON(X) = R then EQ = 1 else? if CON(X)

Explanation / Answer

1st we store 5, 8, X and Y, then load X to the accumulator. Finally add 5 to X. Store X. and do the same with Y.

Program:

ADDRESS INSTRUCTION MACHINE LEARNING OPCODE

1000 IN X; 1101 0000000000001001

1001 IN Y; 1101 0000000000001010

1010 IN A; 1101 0000000000001011 // Put 5 in memory cell A

1011 IN B; 1101 0000000000001100 // Put 8 in B

1100 LOAD X; 0010 0000000000001101 // R = CON(X)

1101 ADD A; 0011 0000000000001110 // R = R+A

1110 STORE X; 0001 0000000000000111 // X = R

1111 LOAD Y; 0000 0000000000001000 // R = Y

00001 SUB B; 0101 0000000000001001 // R = R-B;

00010 STORE Y; 0110 0000000000001010 // Y = R;