SECTION .text ALIGN 16 BITS 32 GLOBAL _RECSUM _RECSUM: ; Define PROC RECSUM PUSH EBP; Save the BP value in the caller's context MOV EBP,ESP; EBP now reflects the callee's context CMP DWORD [EBP+8],1; Since EBP was pushed, parameter is now at EBP+8 JNE L1 MOV EAX,1 ; parameter is 1, terminate recursion and return 1 POP EBP ; Restore EBP to caller's context before returning RET 4; Return to caller after popping 4 bytes of stack (the parameter) ; argument > 1, make a recursive call ; First decrement argument L1: MOV EBX,[EBP+8] DEC EBX PUSH EBX; The decremented argumented now becomes parameter for ; next recursive call CALL _RECSUM ; If you are at this line, you just returned from a recursive call ADD EAX,[EBP+8]; Upon return, add argument to this call which is still on stack ; to result of recursive call in EAX POP EBP; Restore EBP to caller's context before returning RET 4; Pop 4 bytes i.e. argument from stack and return