flat assembler
Message board for the users of flat assembler.

Index > OS Construction > MOD vs divide

Author
Thread Post new topic Reply to topic
me239



Joined: 06 Jan 2011
Posts: 200
me239
Ok, this may sound crazy, but I just really wanted to know If I'm the only one who sees this. Here is the code\equation I've seen on http://www.brokenthorn.com/Resources/OSDev6.html
It says that "absolute sector = (logical sector / sectors per track) + 1", but the code goes as
Code:
LBACHS:
          xor     dx, dx                              ; prepare dx:ax for operation
          div     WORD [bpbSectorsPerTrack]           ; divide by sectors per track
          inc     dl                                  ; add 1 (obsolute sector formula)
          mov     BYTE [absoluteSector], dl    

Isn't this code MODing the sectorspertrack rather than just dividing?
Post 29 May 2011, 06:13
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Yes it is. The "/" in the equation should be read MOD. Also, if by "absolute sector" the documentation really means CHS sector (normally [1..63]), notice how wrong it would be a division there as it could easily exceed 63.
Post 29 May 2011, 06:43
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 707
Location: Adelaide
sinsi
If they used AL then the mod result would apply but they are using DL which is the remainder of the div.
Post 29 May 2011, 08:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.