Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 28th, 2004, 5:40 PM   #1
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Sorry for all these questions in a row, but I want to get some practice on assembly. I was thinking about writing a program that would calculate prime numbers up to a certain number, but couldn't think of any way to find the remiander of a number. Anyone want to point me in a direction I could learn?
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Nov 28th, 2004, 6:00 PM   #2
Eggbert
Professional Programmer
 
Eggbert's Avatar
 
Join Date: Nov 2004
Posts: 250
Rep Power: 4 Eggbert is on a distinguished road
Your assembler doesn't have a MOD operator or something similar? It's a fairly common arithmetic operation.
Eggbert is offline   Reply With Quote
Old Nov 28th, 2004, 6:56 PM   #3
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Doesn't seem to recognize the mod instruction. I'm using NASM if that helps.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Nov 29th, 2004, 1:59 AM   #4
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4 lostcauz is on a distinguished road
I've had a few cocktails but I'll do my best. Using a div instruction, load (e)ax with the number being tested then load cx with the divisor. Then use the instruction - div cx. The quotient will be in ax while the remainder, if any, will be left in dx.
mov cx, 3
mov ax, 31
div cx
You could try this code in debug and watch the registers to see whats going on.
At command line type 'debug'
type 'a'
enter the code above
when done click enter twice then type 'r'
type 't' to execute the next instruction and see the registers change.
In the end ax should be 10 while dx contains the remainder of 1.
Forgive if this makes no sense.
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:37 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC