global fun extern push_stack extern pop_stack extern malloc extern free extern printf extern getchar extern Free extern Malloc section .bss section .text ; ;/* RECURSION IN C */ ; ;void fun(int a) { ; if(a != 10) { ; fun(a+1); ; } ;} fun: push ebp mov ebp,esp mov edx,[ebp+8] push edx push .L0 call push_stack jmp fun0 .L0: add esp,8 leave ret fun0: push ebp call push_stack add esp,4 mov ebp,esp push dword 4 call Malloc add esp,4 push eax call push_stack add esp,4 mov edx,[ebp+4] mov ebp,eax mov eax,[ebp] mov [ebp],eax inc edx pushad push edx push C1 call printf add esp,8 popad mov eax,edx cmp eax,10 je .L0 push edx push dword .L1 call push_stack jmp fun0 .L1: add esp,4 .L0: call pop_stack push eax call Free add esp,4 call pop_stack mov ebp,eax call pop_stack mov ecx,eax jmp ecx section .data C1: db 'n=%d',10,0