I've been working busily on a bootloader, that loads a program from a floppy. However whenever I run it, I get the BIOS screen followed by my program running (the floppy drive becomes active) and then it just stops, reboots the computer and i see the BIOS screen again and the cycle continues...
Any help?
Thanks in advance.
Code: Select all
[BITS 16]
[ORG 0X7C00]
; enable a20
cli
call kbd_wait
mov al, 0xD1
out 0x64, al
call kbd_wait
mov al, 0xDF
out 0x60, al
call kbd_wait
sti
; load kernel
rstdrive:
mov ax, 0x00
int 0x13
or ah, ah
jnz rstdrive
mov ax, 0xFFFF
mov es, ax
mov bx, 0x10
mov ah, 0x02
mov al, 0x02
mov ch, 0x00
mov cl, 0x02
mov dh, 0x00
int 0x13
or ah, ah
jnz rstdrive
;enter pmode and load gdt
cli
xor ax, ax
mov ds, ax
lgdt [GDT_DESC]
mov eax, cr0
or eax, 1
mov cr0 eax
jmp GDT_CODE:bit32_clearpipe
[BITS 32]
bit32_clearpipe:
; setup stack and regs
mov ax, 0x1D00
mov ds, ax
mov ss, ax
mov esp, 0x200
; jmp to kernel code
jmp GDT_CODE:0x100000
hlt
GDT:
GDT_NULL equ $-GDT
dd 0x00
dd 0x00
GDT_CODE equ $-GDT
dw 0x0FFFF
dw 0x00
db 0x00
db 10011010b
db 11001111b
db 0x00
GDT_DATA equ $-GDT
dw 0x0FFFF
dw 0x00
db 0x00
db 10010010b
db 11001111b
db 0x00
GDT_END:
GDT_DESC:
dw GDT_END - GDT - 1
dw GDT
kbd_wait:
kdb_clr:
in al, 0x64
test al, 2
jnz kbd_clr
ret
TIMES 510-($-$$) db 0
SIGNATURE dw 0xAA55