There are several problems in your code:
- You're missing lower byte of base´s high word in your
gdt_code
descriptor. Simply adddb 0x0
afterdw 0x0
. - Frank Kotler wrote that
gdt_descriptor
must contain linear address. Yes, that's true, but it's not the only place where linear address is required. You can useORG
directive before any code, or manually add origin to this field. - Instruction
lgdt
still usesds
register forseg:off
address calculation. You should have it set to zero when writing code underorg
. - Far jump to the protected mode also needs linear address used as offset. Remember that this jump is executed in compatibility mode (as it's the first instruction executed after protected mode switch). It uses two bytes for segment selector (before colon) and only two bytes for offset (after colon). That means you shouldn't try to jump to address higher than
0xFFFF
. Again, check origin of your code.