GDT=0 problem
Posted: Sat Oct 23, 2010 3:18 pm
Hey, I'm trying to load in a GDT for my second stage boot-loader, but for some reason the gdt always equals 0 after loading it. Here's the code
Any ideas?
Code: Select all
[BITS 16]
global ssblstart
ssblstart:
; Set our data segment
cli ; Clear instructions
xor ax, ax
mov ds, ax
mov es, ax
mov ax, 0x9000 ; set stack at 0x9000-0xffff
mov ss, ax
mov sp, 0xFFFF
pusha
lgdt [TGDT]
popa
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 0x8:PmodeE ; <-- this will cause qemu to crash, pretty sure its because the GDT is essentially null.
[BITS 32]
PmodeE:
cli
mov ax, 0x10 ; set data segments to data selector (0x10)
mov ds, ax
mov ss, ax
mov es, ax
mov esp, 90000h
cli
hlt
data:
greeting2 db 'A'
error db '2'
load db '3'
;========================================
;===================GDT==================
;========================================
BGDT:
; Null
dd 0
dd 0
; Code
dw 0xFFFF ; limit low
dw 0 ; base low
db 0 ; base middle
db 10011010b ; access
db 11001111b ; granularity
db 0 ; base high
; Data
dw 0xFFFF ; limit low
dw 0 ; base low
db 0 ; base middle
db 10010010b ; access
db 11001111b ; granularity
db 0 ; base high
EGDT:
TGDT:
dw EGDT - BGDT - 1 ; limit (Size of GDT)
dd BGDT