i see a bootloader for in pmode code with nasm:
the snipe is gdt,but i no found gdt define,i dont know if gdt is a const,is it right?

dw gdt_end-gdt-1 ; gdt's length
dd gdt ; gdt's baseadr
gdt
nullsel equ $-gdt ;nullsel = 0h
gdt0 ; null sel
dd 0
Posted on 2004-04-19 03:56:27 by bgcq

i see a bootloader for in pmode code with nasm:
the snipe is gdt,but i no found gdt define,i dont know if gdt is a const,is it right?

dw gdt_end-gdt-1 ; gdt's length
dd gdt ; gdt's baseadr
gdt
nullsel equ $-gdt ;nullsel = 0h
gdt0 ; null sel
dd 0


In this case, "dd gdt" defines a 32-bit variable named "gdt". The next line "gdt" is merely a label, which makes it more or less a constant. When NASM assembles this, anything that calls for "gdt" looks to that line as a constant (memory pointer) based on the offset from whatever the program origin is.
Posted on 2004-04-19 04:11:52 by SpooK
but i feel label must have colon (':'),such as 'gdt:',
if gdt is label,then in code,have
gdt0
code_gdt
data_gdt
they all are label?
and if

org 100h
dw gdt_end-gdt-1 ; gdt length
dd gdt ; gdt baseadr
gdt

then gdt 's value is 103h?
Posted on 2004-04-19 04:40:13 by bgcq

but i feel label must have colon (':'),such as 'gdt:',
if gdt is label,then in code,have
gdt0
code_gdt
data_gdt
they all are label?


Giving the label a colon (:) is optional in NASM. Bascially anything that isn't predefined in NASM is considered a label. Some people feel more comfortable not using the colon (:) to specify labels, personally I tend to state my labels as such.
VARIABLE_NAME DD 0

SUBROUTINE_POINTER:
;do some fun asm stuff here

Either way is acceptable to NASM.


org 100h
dw gdt_end-gdt-1 ; gdt length
dd gdt ; gdt baseadr
gdt

then gdt 's value is 103h?


Technically, "dd gdt" fills up 4 bytes of data (32-bit address of gdt), so "gdt" is actually 107h (it's location in the code).
Posted on 2004-04-19 10:34:08 by SpooK
thanks you answer,i know what's mean now.and i have a new problem,i before use from real mode to pmode in one file by bootloader ,it is work ok.now i want to move pmode to a another file,when it enter pmode,the bochs is restart:<,i feel there will be set offset of gdt,but dont know how to set ,i use ,it was wrong too.can you help me too?
Posted on 2004-04-20 05:22:46 by bgcq
Also there is a cmd line option called -orphan-labels or some like that, I dont use much, but that will trow a warning for things like

gdt

where gdt is not a mnemonic or label, htat will cause that nasm require always the ':'

Have a nice day or night.
Posted on 2004-04-21 13:03:55 by rea