SECTION .text ALIGN 16 BITS 32 GLOBAL _factorial _factorial: ; function returns n! when called as factorial(n) ; return value is expected in EAX by DJGPP compiler ; move (copy) number from stack into register EAX MOV ECX,[ESP+4] MOV EAX,1 CMP ECX,0 JBE L2 ; jump to L2 if parameter <= 0, return 1 L1: MUL ECX ; Perform EDX:EAX = EAX*ECX LOOP L1 ; decrement ECX and go to L1 if ECX != 0 L2: RET ; Return to calling program.