EE 3750 โ HW 2 solutions 1
EE 3750 โ Homework 2 solutions
Fall 2009
1. Write an 8086 instruction sequence to subtract BX and DX from SI and then divide
the result by CH. Assume that all numbers are signed binary integers. The final quotient must
be an 8-bit number stored in the AL register, and all registers other than AX (that is, AH and AL)
should hold the same contents at the end of the sequence as they held at the beginning of the
sequence.
MOV AX, SI ; only AX can change, so manipulate in AX
SUB AX, BX
SUB AX, DX
IDIV CH ; quotient of AX/CH is in AH
2. Given the register and memory contents listed below, list the changed registers and
memory locations and their contents after each instruction below executed in sequence.
Contents: All integers in this problem are written in hexadecimal. Let AX = 2204, BX =
1230, CX = 1E36, DX = 7A95, SI = 4488, DI = 8B14, SP = 386, SS = A000, ES = 5000, and DS
= 8000. Let DF = 0, contents of the word pointed to by DS:[SI] = 45A6, contents of the word
pointed to by DS:[SI+8] = 8086, and let each other byte in memory hold 3C.
SUB CX, AX
SBB DX, BX
LEA BX, [SI+8]
MOVSB
PUSH AX
POP DI
SUB CX, AX : CX โ FC32
SBB DX, BX : DX โ 6864 (note that CF was 1 because of the borrow during
the SUB instruction)
LEA BX, [SI+8] : BX โ 4490
MOVSB : byte in memory at physical address 58B14 (5000:8B14) โ A6;
DI โ 8B15; SI โ 4489
PUSH AX : SP โ 384;
top of stack at physical address A0384 (A000:384) โ 2204
POP DI : DI โ 2204; SP โ 386