You want
mul ebx
The eax
is implicit. What mul ebx
does is ebx*eax
and stores the result in edx:eax
(the higher order bits go in edx
when eax
is not big enough to hold the result, in your example this is not a problem though).
Note that you have two parallel counters in n
and ecx
. You can get rid of one to make your code shorter:
.code
start:
mov ecx, 5
mov eax, 1
Top:
mul ecx
dec ecx
jnz Top
mov res, eax
Even shorter, you can replace the two lines dec ecx, jnz Top
by loop Top
. Now that's some short and sweet factorial function!