flat assembler
Message board for the users of flat assembler.

Index > Main > I need some help with Descriptors, please!

Author
Thread Post new topic Reply to topic
cb-toledo



Joined: 06 May 2005
Posts: 2
Location: Brazil
cb-toledo
My little problem:

consider this program...
my_program: ....some code
end_program: endp

The extension of this my-program is end_program-my_program

Consider also address base and the extension of my_program are
both 32 bits large...

Now, I want to build a GDT descritptor

seg_limit dw
base_address0 dw
base_address1 db
descriptor_type db 0x9a
compl_byte db... (half byte is part of limit)
base_address2 db...


My problem is: How can I break my_program base address and my_program extension for to put these in a GDT descriptor using FASM Assembler?
Post 29 May 2005, 15:26
View user's profile Send private message Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85
Why not you define a flat code segment? I.e.
Code:
SysCodeSel = $ - GDT
        dw 0xffff
        dw 0x0000
        db 0x00
        db 0x9a         ; present, ring 0, code, non-conforming, execute/read
        db 0xcf
        db 0x00    


But to use a segmented model, it's the base address and program size constant? I guess it is, so you can get the preprocessor to do the job.
Code:
SysCodeSel = $ - GDT
        dw end_program and 0xffff
        dw my_program and 0xffff
        db my_program shr 16 and 0xff
        db 0x9a         ; present, ring 0, code, non-conforming, execute/read
        db 0xc0 or end_program shr 16 and 0xf
        db my_program shr 24 and 0xff    


There's is an aside in this model. This base address is added to every address refered via CS. So if tell Fasm to use 0x1000 as base for my_program, "jmp my_program" will really jump to 0x2000. You could use "org 0" and put in the GDT the address where the file is loaded in memory by the bootloader. Sorry if I was not clear.

PS: This kind of questions should be posted in the "OS Construction" section.

_________________
"I assemble, therefore I am"

If you got some spare time, visit my blog: http://www.beppe.theblog.com.br/ and sign my guestmap
Post 29 May 2005, 23:18
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 YouTube, Twitter.

Website powered by rwasa.