![]() |
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?
|
Your assembler doesn't have a MOD operator or something similar? It's a fairly common arithmetic operation.
|
Doesn't seem to recognize the mod instruction. I'm using NASM if that helps.
|
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, 3At 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. :mrgreen: |
| All times are GMT -5. The time now is 6:20 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC