Thread: Remainder
View Single Post
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