Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-07-2004, 12:25 PM   #1
LQ Newbie
Registered: Sep 2004
Distribution: Suse 9.2
Posts: 21

Rep: Reputation: 15
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
Old 10-07-2004, 12:36 PM   #2
Senior Member
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
DIV: Divides two unsigned integers (always positive)
IDIV: Divides two signed integers (either positive or negitive)

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?
Old 10-07-2004, 12:42 PM   #3
LQ Newbie
Registered: Sep 2004
Distribution: Suse 9.2
Posts: 21

Original Poster
Rep: Reputation: 15
great, thanks alot, it works now


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bc: using -l messes up modulus Ephracis Programming 4 06-07-2005 01:34 PM
Divisibility without using modulus redhatrosh Programming 1 03-01-2005 10:02 PM
I need help for Assembly skb Programming 10 08-01-2003 04:51 PM
assembly genghis Programming 2 06-12-2003 07:46 AM
assembly sanjay pradhan Programming 1 02-01-2002 10:05 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:22 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration