Sam Finch
Oct 21st, 2000, 01:55 PM
I'm just starting with this crazy language and in theory this is a function that calculates the factorial of an integer (I'm using inline assembly in VC++)
int factorial(int number)
{
int i;
__asm
{
mov eax, 1 ; eax is the return value (start at 1)
mov ebx, 0 ; ebx is the counter
mov ecx, number ; ecx is the number we are counting to
strt: ; Start of loop
add ebx, 1 ; add 1 to the counter
mul eax, ebx ; multiply by the counter (at this point eax = ebx!)
cmp ebx, ecx ;*************
jl strt ; If the counter is less than number go back to the start of the loop
}
}
but it refuses to complile, it claims there is an error (illegal number of operands) on the
cmp ebx, ecx
line (marked with a big load of stars)
i'm pretty sure it requires 2 operands, and I'm pretty sure I gave it 2 operands, so why won't it work
int factorial(int number)
{
int i;
__asm
{
mov eax, 1 ; eax is the return value (start at 1)
mov ebx, 0 ; ebx is the counter
mov ecx, number ; ecx is the number we are counting to
strt: ; Start of loop
add ebx, 1 ; add 1 to the counter
mul eax, ebx ; multiply by the counter (at this point eax = ebx!)
cmp ebx, ecx ;*************
jl strt ; If the counter is less than number go back to the start of the loop
}
}
but it refuses to complile, it claims there is an error (illegal number of operands) on the
cmp ebx, ecx
line (marked with a big load of stars)
i'm pretty sure it requires 2 operands, and I'm pretty sure I gave it 2 operands, so why won't it work