10.2. Homework - x86 Assembly LanguageΒΆ
Decompile the following assembly language code to the original C code. You may to draw a memory map as an aid.
.sect .text; .sect .rom; .sect .data; .sect .bss
.extern _main
.sect .text
_main:
push ebp
mov ebp,esp
push 3
call _f
pop ecx
push eax
push I_1
call _printf
pop ecx
pop ecx
xor eax,eax
leave
ret
.sect .rom
I_1:
.extern _f
.data4 680997 # ASCII for "%d\n"
.sect .text
_f:
push ebp
mov ebp,esp
push esi
cmp 8(ebp),1
jg I2_4
mov esi,1
jmp I2_5
I2_4:
mov edx,8(ebp)
dec edx
push edx
call _f
pop ecx
mov edx,8(ebp)
sub edx,2
push eax
push edx
call _f
pop ecx
pop esi
add esi,eax
I2_5:
mov eax,esi
pop esi
leave
ret