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

1. (8 pts) Execute the following assembly instructions and determine the result

ID: 3859524 • Letter: 1

Question

1. (8 pts) Execute the following assembly instructions and determine the result ebp = 0x127AC char B128 ebp 5 int resulti ebp 4) a. movs x eax, Bi mov result,eaxi result - b. mov zx eax, B; mov result, eax; re sult c. xor eax, eaxi mov result,eax result- d. mov sxeax,B; neg eax ; mov result,eax; result . e.mov z x eax, B; neg eax ; mov result, eax; result f. lea eax, B; mov result, eax; result = F. lea eax, B mov result, eax; result g. push 0x80; mov eax, [espmov result,eax; result h. mov al,0x80 cmp al,0x7A; jg exit; Is the jump taken? Explain why or why not.

Explanation / Answer

1.

Ebp = 0x127AC

Char B = -128; -128 = FFh (2’s compliment)

int result

a.            movsx   eax,B;   mov result, eax;                               result = FFFFFFFFh; movsx movs along with the signed bits here FF is negative so it puts all the remaining bits as 1’s.

b.            movzx   eax,b;   mov result, eax;               result= 000000FFh; movzx moves the remaining bits as zeros.

c.             xor         eax,eax; mov result,eax;              result= FFh; XOR with the same register does nothing;

d.            movsx   eax,B;   neg eax;               mov result,eax; result= 00000000; negate will reverse all the bits, here all the bits are changed from 1 to 0;

e.            movzx   eax,B;   neg eax;               mov result,eax; result= FFFFFF00; negate will reverse all the bits, here all the bits are changed from 1 to 0 and 0 to 1;

f.             lea          eax, B; mov result, eax;                               result=0x05;       lea loads the effective address. Here effective address is 5 as shown in the above;

g.            push      0x80;     mov eax,[esp];                 mov result, eax;                               result= 0x80;      here when the push 0x80 is executed, stack value is 8x and esp contains the address of that stack, when mov eax,[esp] is executed, the value in the stack is copied to eax;

h.            mov al, 0x80;      cmp al,0x7A;      jg exit; Here jmp executes as al contains 80, and it compared with 07A, 80 is greater than 7A, so the jump if greater instruction executed.