1. Each of these problems gives \"before\" conditions and an instruction. Give t
ID: 3833875 • Letter: 1
Question
1. Each of these problems gives "before" conditions and an instruction. Give the indicated "after" state.
Before
Instruction executed
After
(a)
ECX: 00 00 BF 7A
mov ecx, -89
ECX
(b)
EAX: 12 34 56 78
EDX: 9A BC DE F0
xchg ax, dx
EAX
EDX
(c)
EAX: FF FF FF C8
add eax, 56
EAX
(d)
EDX: 00 00 02 E9
inc edx
EDX
(e)
EBX: FF FF FF 3B
neg ebx
EBX
(f)
EAX: 01 23 45 67
ECX: 89 AB CD EF
sub eax, ecx
EAX
(g)
EAX: 00 00 00 0A
EBX: FF FF FF FC
EDX: FF 03 FF 01
imul ebx
EAX
EDX
(h)
EAX: 00 00 00 10
ECX: FF FF FF FD
EDX: FF 03 FF 01
mul ecx
EAX
EDX
(i)
EAX: 00 00 00 0A
EBX: 00 00 00 0C
EDX: FF 03 FF 01
imul eax,ebx
EAX
EDX
(j)
EAX: 00 00 0E AA
ECX: 00 00 00 1B
EDX: 00 00 00 00
div ecx
EAX
EDX
(k)
EAX: 00 00 0F CA
EBX: 00 00 00 0D
EDX: 00 00 00 00
idiv ebx
EAX
EDX
2. Implement the design given below. Assume that value is stored as a doubleword in memory, number is in EAX, and count is in ECX.
if value < 1000
then
add 10*count to value;
else
value := 800;
subtract 1 from count;
end if;
3. Implement the design given below. Assume that value is stored as a doubleword in memory, number is in EAX, and count is in ECX.
number := 0;
value := 500;
while number £ 60 and value > 200 loop
subtract number from value;
add 5 to number;
end while;
4. What will EAX contain following execution of the following code?
mov eax, 0
mov ecx, 4
forLoop:
add eax, ecx
loop forLoop
5. Each of these problems gives "before" conditions and an instruction. Give the indicated "after" state.
Before
Instruction executed
After
(a)
EBX: 22 33 44 55
ESP: 00 63 FB 60
push ebx
EBX
ESP
(b)
ESP: 00 63 FB 60
Ret
ESP
(c)
ESP: 00 63 FB 60
proc3 is a procedure at address 00 40 5B C8
call proc3
ESP
(d)
EDX: 12 AB FF FD
ESP: 00 63 FB 54
push edx
EDX
ESP
(e)
ESP: 00 63 FB 54
Ret
ESP
(f)
ESP: 00 63 FB 54
proc3f is a procedure at address 00405B72
call proc3f
EIP
(c)
EAX: FF FF FF C8
add eax, 56
EAX
Before
Instruction executed
After
(a)
ECX: 00 00 BF 7A
mov ecx, -89
ECX
(b)
EAX: 12 34 56 78
EDX: 9A BC DE F0
xchg ax, dx
EAX
EDX
(c)
EAX: FF FF FF C8
add eax, 56
EAX
(d)
EDX: 00 00 02 E9
inc edx
EDX
(e)
EBX: FF FF FF 3B
neg ebx
EBX
(f)
EAX: 01 23 45 67
ECX: 89 AB CD EF
sub eax, ecx
EAX
Explanation / Answer
As per Chegg policy, I am uploading the four parts of Question 1:
a.) ecx will have 2's complement of 89 which is 0111 0111
b.) xchg command swap the values of ax and dx. So, xchg ax, dx will result in
eax: 12 34 DE F0
edx: 9a BC 56 78
c.) adding 56 to eax result in overflow. Now, EAX will have value 00 00 00 2E
d.) inc edx will result in addition of 1. Now, edx will have 00 00 02 EA
Hope it helps, do give your response.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.