4. Using the x86’s register and memory contents from problem #3, indicate the st
ID: 2072474 • Letter: 4
Question
4. Using the x86’s register and memory contents from problem #3, indicate the state of the x86 ’s SF, ZF, and OF flags after the execution of each instructions?
a. CMP [BP], AL
b. CMP SP, 01F1
c. CMP DATAV, 01H
EAX 300001011H EBX 00000022H ECX 00000105H EDx 000055A AH ESI 0000AA55H EDI 000000220H EBP 000000200H ESP 000008001H CF 30 DATA W 000011 11H DATAV 000000F0H SS:200H 22H SS: 210H 355H SS:211H AAH SS:420H AAH SS:421H 55H DS:100H FOH DS: 201H 344H DS 202H 300H DS 203H 300H DS: 230H AAH DS 231H 55H DS:400H AAH DS:401H 55H DS:3A0H 3AAHExplanation / Answer
the execution of CMP op1, op2 involves the operation of op1-op2 and the result is not stored anywhere but the flags are affected accordingly.
(a) CMP [BP], AL:
BP is having a data of 00000200H (0x200). [BP] is the data present at the location pointed to by BP i.e., the data 0x200 will now act as an address and hence [BP] is 22H.
EAX=00001011H in which the lower 16 bits is the register AX. there fore, AX=1011H in which the lower 8 bits is the register AL. hence AL=11H.
now CMP [BL], AL is subtracting 22H and 11H which results in 11H (not stored anywhere). the flags are affected accordingly. but this execution will not affect any flags as neither of sign change, zero result, overflow has occured.
(b) CMP SP, 01F1H
ESP is 00008001H in which the lower 16 bits is the SP = 8001H
now 8001H-01F1H also does not affect any flags because operand 1 is greater than operand 2.
(c) CMP DATAV, 01H
DATAV=F0H which is greater than 01H and hence no flags are affected.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.