So I'm trying to write a non-recursive of factorial procedure uses loop instruction, that parameter is passed through runtime stack.
I also need sequence of instruction in main PROC to invoke factorial procedure. Anybody want help me with this part, this what I have so far.
.IF eax == 0 || eax == 1 ;special cases
mov eax, 1 ;factorial == 1
jmp L2 ;quit procedure
.ELSEIF eax > 12 ;n is too large
mov edx, OFFSET msgError
call Crlf
call WriteString
jmp L2 ;quit procedure
.ENDIF
mov ecx, eax ;ecx = counter
L1:
dec ecx ;ecx = n - 1
mul ecx ;eax = n * (n - 1)
cmp ecx, 1 ;is counter > 1?
ja L1 ;true? then continue
L2:
ret
nonRecurFact ENDP