Message board for the users of flat assembler.
> Main > I need some help with Descriptors, please!
My little problem:
consider this program...
my_program: ....some code
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
descriptor_type db 0x9a
compl_byte db... (half byte is part of limit)
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?
|29 May 2005, 15:26||
Why not you define a flat code segment? I.e.
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.
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
|29 May 2005, 23:18||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.