Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
[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
I don't see an org directive, I don't see documented what value CS will be having. As far as this code tells me, your second stage looks like it must be loaded at 0x00000 physical, which is wrong because it means overwriting the IVT and ruining your access to the BIOS.
And that is also the location you tell the processor to use when it has to look for the GDT.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
since you are apparently doing things the difficult way, would you post the file offset and disassembly of the following lines so we can check if it is your understanding of the linker that's wrong or not:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]