I am working on an os
The os freezes after running finished the bootloader.
Any idea why?
Code: Select all
;==========================================
; nasmw boot.asm -o boot.bin
; partcopy boot.bin 0 200 -f0
[ORG 0x7c00] ; add to offsets
jmp start
%include "print.inc"
start: xor ax, ax ; make it zero
mov ds, ax ; DS=0
mov ss, ax ; stack starts at 0
mov sp, 0x9c00 ; 200h past code start
cli ; no interrupt
push ds ; save real mode
mov si, startmsg
call sprint
mov si, gdtmsg
call sprint
lgdt [gdtinfo] ; load gdt register
mov eax, cr0 ; switch to pmode by
or al,1 ; set pmode bit
mov cr0, eax
mov bx, 0x08 ; select descriptor 1
mov ds, bx ; 8h = 1000b
and al,0xFE ; back to realmode
mov cr0, eax ; by toggling bit again
pop ds ; get back old segment
sti
mov si, donemsg
call sprint
jmp 08h:kernelstart
jmp $ ; loop forever
[BITS 32]
kernelstart:
mov ax, 10h ; save data segment
mov ds, ax ; setup data segment
mov ss, ax ; setup stack segment
mov esp, 090000h ; move the stack pointer to 090000h
jmp 08h:1000h ; jump to our kernel
gdtinfo:
dw gdt_end - gdt - 1 ;last byte in table
dd gdt ;start of table
gdt dd 0,0 ; entry 0 is always unused
flatdesc db 0xff, 0xff, 0, 0, 0, 10010010b, 11001111b, 0
startmsg db 'OS Startup.', 0
gdtmsg db 'Test', 0
donemsg db 'Done!', 0
gdt_end:
hlt
times 510-($-$$) db 0 ; fill sector w/ 0's
db 0x55 ; req'd by some BIOSes
db 0xAA
;==========================================

