EE 3750 — Test 1 solutions 1
EE 3750 — Test 1 solutions
Fall 2008
1. (20 pts) Consider each of the instructions below, executed separately (not in
sequence), with initial register values (in hexadecimal) as follows: AX = 4234, BX = 0A0A, CX
= 4FFF, DX = 4947. For each instruction, identify the result of the instruction that is stored in
AH and specify the resulting SF, PF, and ZF flags.
AND AH, DL
ADD AH, DL
AND: AH ← 42H (= 0100 0010 B); SF = 0, PF = 1, ZF = 0
ADD: AH ← 89H (= 1000 1001 B); SF = 1, PF = 0, ZF = 0
2. (20 pts) For the sequence of instructions below, let the offset of green be 620 and the
offset of brown be 8C6, and let the registers have the following initial contents: DS = 2000, ES
= 3500, SI = 227, DI = 4D6, CX = 22, where all values are in hexadecimal.
(a) Specify the contents of all registers changed by the instruction REP MOVSW.
(b) Explain what this sequence of instructions accomplishes.
(c) Write an 8086 assembly language instruction sequence to accomplish the same result,
but without using any string transfer instructions.
CLD
PUSH DS
POP ES
MOV SI, OFFSET GREEN
LEA DI, BROWN
MOV CX, 4
REP MOVSW
(a) SI = 628H (620 + 8)
DI = 8CE (8C6 + 8)
CX = 0
(b) REP MOVSW copies four words from array green to array brown.
(c)
MOV CX, 4 ; to copy 4 times
MOV BX, 0
TOP; MOV AX, GREEN[BX]
MOV BROWN[BX], AX ; copies word from green to brown
ADD BX, 2 ; update pointer
LOOP TOP