. Write a sequence of instructions to compute the following arithmetic expression and store the result in register DX: 7 + (-20) * 14 - (-10) * 8– 9
Trace the contents of registers, assume initial contents are 0000
Instruction |
AX |
BX |
CX |
DX |
Remark |
initial |
0000 |
0000 |
0000 |
0000 |
The sequence of instructions are as follows:
1.MOV AX,-20
2. MUL AX,14
3. MOV BX,-10
4. MUL BX,8
5. MOV CX,9
6. SUB AX,BX
7. SUB AX,CX
8. MOV DX,7
9. ADD DX,AX
The content of registers are shown as below:
Instruction | AX | BX | CX | DX | Remark |
Initial | 0 | 0 | 0 | 0 | |
MOV AX,-20 | -20 | 0 | 0 | 0 | Move -20 to Register AX |
MUL AX,14 | -280 | 0 | 0 | 0 | Multiply 14 to Register AX |
MOV BX,-10 | -280 | -10 | 0 | 0 | Move -10 to Register BX |
MUL BX,8 | -280 | -80 | 0 | 0 | Multiply 8 to Register BX |
MOV CX,9 | -280 | -80 | 9 | 0 | Move 9 to Register CX |
SUB AX,BX | -200 | -80 | 9 | 0 | Subtract BX from AX and store the result in AX |
SUB AX,CX | -209 | -80 | 9 | 0 | Subtract CX from AX and store the result in AX |
MOV DX,7 | -209 | -80 | 9 | 7 | Move 7 to Register DX |
ADD DX,AX | -209 | -80 | 9 | -202 | Add DX and AX and store the result in DX |
Get Answers For Free
Most questions answered within 1 hours.