flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Conserving space?

Author
Thread Post new topic Reply to topic
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Hey! I was just working on another small OS for fun, and I noticed something:

If I have my 16-bit startup code, then my GDT between that and my 32-bit code, it results in a smaller size than if I had my GDT at the bottom.

Here's an better depiction:

Code:
ORG 7C00h

START16:
...
   jmp 08h:START32

GDT:
...

START32:
...

INFINITE_LOOP:
   jmp INFINITE_LOOP
TIMES 510-($-$$) db 0
dw AA55
    


Comes out smaller than the following:
Code:
ORG 7C00h

START16:
...
   jmp 08h:START32

START32:
...

INFINITE_LOOP:
   jmp INFINITE_LOOP

GDT:
...

TIMES 510-($-$$) db 0
dw AA55
    


Does anyone know why?

P.S. - When I say GDT, I mean the GDT itself and the descriptor.
Post 12 Oct 2006, 04:59
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
If anyone needs more real code as opposed to pseudocode to understand what I mean, I can show you the code from my TinyOS where I learned of this happening.
Post 13 Oct 2006, 22:13
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Does anyone know why it may be doing this? I mean, if the GDT is like it is in the second bit of code, it gets above 512, and I have to start subtracting zeros from the TIMES 510-($-$$) db 0, but if it's like it is in the first code clip, it doesn't take up nearly as much space.
Post 14 Oct 2006, 20:32
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
I just started putting the IDT into my OS, and it's the same idea, that as long as the GDT and IDT are in between the 16-bit and 32-bit code, it stays small.
Post 15 Oct 2006, 02:07
View user's profile Send private message Reply with quote
Goplat



Joined: 15 Sep 2006
Posts: 181
Goplat
I can't think of any reason, but the easiest way to find out would probably be to just look at the two files side by side in a hex editor.
Post 15 Oct 2006, 02:07
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
We can't help you if you don't post your code.
Post 15 Oct 2006, 02:20
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Okay... Now I'm embarrassed... I tried it again, and it stayed small... The stupid thing I did was I put the GDT after the times 510 and end of bootsector signature when I did it before... Sorry!
Post 15 Oct 2006, 02:52
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.

Powered by rwasa.