Implement c++ design given below. Assume that value is stored as a doubleword in memory, number is in EAX, and count is in ECX. You need only show the assembly code for the design. Submitting entire programs is not necessary
if (value < 1000)
value = value+10*count;
else {
value = 800;
count--;
}
mov eax, 10 ; eax = 10
mov ecx, count ; load count to ecx
cmp value, 1000 ; compare value with 1000
jl Then_ ; if(value<1000) goto Then_
; else
mov value, 800 ; value:=800
dec count ; subtract 1 from count
jmp End_If ; goto End_If
Then_:
mul ecx ; 10*count
add value, eax ; value = value + 10*count
End_If:
Comments
Leave a comment