In bootasm.S
.p2align 2 # force 4 byte alignment
gdt:
SEG_NULLASM # null seg
SEG_ASM(STA_X|STA_R, 0x0, 0xffffffff) # code seg
SEG_ASM(STA_W, 0x0, 0xffffffff) # data seg
gdtdesc:
.word (gdtdesc - gdt - 1) # sizeof(gdt) - 1
.long gdt # address gdt
And this is used in
lgdt gdtdesc
Shouldn't the first word of gdtdesc be the size of gdt in bytes? In this case, it's 3*8=24, which equals to gdtdesc - gdt.
Why gdtdesc - gdt - 1 here?