; School of Computer Engineering ; K.N. Toosi University of Technology %include "asm_io.inc" segment .text global asm_main asm_main: enter 0,0 pusha ;; ========================== ;; compute fact(4) push 4 call fact add esp, 4 call print_int call print_nl ;; ========================== popa leave ret fact: push ebp mov ebp, esp mov eax, [ebp+8] cmp eax, 0 jg recur mov eax, 1 jmp endfact recur: dec eax push eax call fact add esp, 4 imul dword [ebp+8] endfact: pop ebp ret