LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Modulus in Assembly How? (https://www.linuxquestions.org/questions/programming-9/modulus-in-assembly-how-239876/)

browneyes 10-07-2004 12:25 PM

Modulus in Assembly How?
 
I need help how do I get the modulus/remainder in assembly language in intel syntax? is it mod?


mov dword [years], 7

mov ax, word [years]

mod word [months] <--- Line 79
mov [i], ax

mov eax, 0
mov ax, [i]
push eax
push string4
call printf
add esp, 8

I'm getting this error:

linux2[27]% make
nasm -g -f elf xxxx.asm
xxxx.asm:79: error: parser: instruction expected
make: *** [xxxx.o] Error 1

itsme86 10-07-2004 12:36 PM

Quote:

DIV: Divides two unsigned integers (always positive)
IDIV: Divides two signed integers (either positive or negitive)
Syntax:

DIV register or variable
IDIV register or variable

This works in the same way as MUL and IMUL by dividing the number in AX by the register or variable given. The answer is stored in two places. AL stores the answer and the remainder is in AH. If the operand is a 16 bit register than the number in DX:AX is divided by the operand and the answer is stored in AX and remainder in DX.
Is that what you're looking for?

browneyes 10-07-2004 12:42 PM

great, thanks alot, it works now


All times are GMT -5. The time now is 05:31 AM.