modulo

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
killedbydeath

modulo

Post by killedbydeath »

ive been reading this artice for fat
http://scottie.20m.com/fat.htm

It says :

Now that we know the logical sector, you might be wondering
how to get it to absolute sector so we can read it. Well
we use a few formulas to figure it out.
They are:
sector = ( logical sector MOD sector per track) + 1
head = (logical sector \ sector per track ) MOD number of heads
track = logical sector \ (sector per track * number of heads)

Note that this is integer division instead of floating point
division. And also Modulo math. If you can't figure this out
just turn on QBasic and enter a quick formula.
So. Using the formulas above we get:
sector= (34 MOD 512)+1= 17
head= (34 \ 512) MOD 2= 1
track= 34 \ (512 *2)= 0
Our file starts at Head 1 Track 0 Sector 17
The next sector Head 1 Track 0 Sector 18
The next sector Head 0 Track 1 Sector 1
and so on till the end.
My question is how can i implement modulo, i mean assembly doesn't have a modulo instruction. And mathematicaly modulo has many meanings. Please tell me is there a way to do modulo in assembly and if not can i do the above calculations without modulo?

Best Regards
Kemp

Re:modulo

Post by Kemp »

i mean assembly doesn't have a modulo instruction. And mathematicaly modulo has many meanings.
Mathematically, modulo has one meaning: The remainder after dividing the two numbers. IIRC the assembly division instructions place the remainder into one of the registers.
killedbydeath

Re:modulo

Post by killedbydeath »

http://en.wikipedia.org/wiki/Modulo
^modulo has more than one meaning.
paulbarker

Re:modulo

Post by paulbarker »

When talking about computing, a mod b generally means the remainder when a is divided by b, which is (a % b) in c. For x86 assembly, after doing a div or idiv instruction the quotient will be in one register and the remainder in another, I think. Check the docs and see what you find.

As for uses of the word modulus (which I'm thinking is *not* interchangeable with the word modulo): mod x = |x| = abs(x). This use of 'mod' is pretty rare and is better refered to as "absolute value."

The only place I recall seeing the second use of mod(z) is for complex numbers, and most mathematicians will understand abs(z) so I stick to mod means remainder, abs means absolute. I don't think you will see mod(x) used to mean abs(x) used in any computing docs.

Hope that makes things clear.
Kemp

Re:modulo

Post by Kemp »

What he said ;) Too many words with similar names and different meanings, and too many words with more than one meaning. I have but a simple mind :P
killedbydeath

Re:modulo

Post by killedbydeath »

sure, you're right, in computing theres only one meaning ;D Anyway thank you guys!
Post Reply