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

Microprocessor Question: What is the result of each of the instructions listed a

ID: 3754840 • Letter: M

Question

Microprocessor Question: What is the result of each of the instructions listed and assume the instructions execute in sequence, the results of each instruction may depend on the results of earlier instructions. Correctly evaluate each instruction. Please write all answers in written detail. Thanks. Assume the state of an x86 processor's registers and memory are: EAX: 0xEECE3160 EBX: 0x00000001 ECX: 0x00000002 EDX: 0x00000004 ESI: 0x00020100 EDI: 0x00020110 Address Lo 0x20100 10 00 08 00 0x2010418 10 FF FF 0x20108 08 00 19 91 0x20100 20 4060 82 0x20110 02 00 AB OF 0x20114 30 99 11 55 0x20118 40 AA 7C EE 0x2011d FF BB 42 D2 0x20120 30 CC 30 90 What is the result of each of the instructions listed below? Assume that the instructions execute in sequence-in other words, the result of each instruction may depend on the results of earlier instructions. Correctly evaluating each instruction will earn you 10 points. Note that you may assume any constant values shown using less than 32 bits are zero-extended to 32 bits if necessary (for example, 0x000F 0x0000000F). Also, you may assume little endian representation MOV DL, OxFE MOV DH, AL MOVSx BX, BYTE PTR [ESI+0x000F] MOV [EDI+ECXI, EBX MOV [ESI+4*ECX], AX XCHG CL, [ESI MOVZX EAX, WORD PTR [EDI+ECX MOV DX, (EDI+0xFFFFFFFA] LEA ECX, [ESI+EBX+0x0017] MOVSX EBX, BYTE PTR (ESI+4]

Explanation / Answer

MOV DL, 0xFE

Solution: DL = 0xFE

MOV DH, AL

Solution: DH = AL = 0x70 (EDX now = 0x000070FE)

MOVSX BX, BYTE PTR [ESI+0x000F]

Solution: BX = sign-extended byte at address ESI+0x000F = 0x00020100 + 0x000F = 0x0002010F
-> BX = 0x80 sign-extended = 0xFF80


MOV [EDI+ECX], EBX

Solution: Double-word at address EDI+ECX = EBX   EDI+ECX = 0x00020110 + 0x00000002 = 0x00020112 -> (0x20112) = EBX = 0x0000FF80 (bytes ordered as 0x80, 0xFF, 0x00, 0x00)

MOV [ESI+4*ECX], AX

Solution: Word at address ESI+4*ECX = AX ESI + 4*ECX = 0x20100 + 4 * 2 = 0x20108 -> (0x20108) = 0x3170 (bytes ordered as 0x70, 0x31)

XCHG CL, [ESI]

Solution: Swap byte values in CL, address 0x20110 -> CL = 0x10, (0x20110) = 0x02

MOVZX EAX, WORD PTR [EDI+ECX]

Solution: EAX = zero-extended word at address EDI+ECX = 0x20110 + 0x00000010 = 0x20120 -> EAX = 0x0000CC30 (original word underlined)

MOV DX, [EDI+0xFFFFFFFA]

Solution: DX = word at address EDI+0xFFFFFFFA = 0x20110 + (-6) = 0x2010A -> DX = 0x9119

LEA ECX, [ESI+EBX+0x0017]

Solution: ECX = ESI + EBX + 0x0017h = 0x20100 + 0x0000FF80 + 0x0017h = 0x30097

MOVSX EBX, BYTE PTR [ESI+4]

Solution: EBX = sign-extended byte at address 0x20104h = 0x00000010 (original byte underlined)