Jump into protected mode is fail[solved]
Posted: Mon Mar 11, 2019 12:41 pm
Good day!
I have problem with my bootloader. If I enter into protected mode, qemu is reboot. Please where is bug?
I have problem with my bootloader. If I enter into protected mode, qemu is reboot. Please where is bug?
Code: Select all
bits 16
start:
mov ax, 07C0h ;set data segment
mov ds, ax ;load number into register
mov sp, 4096 ;set stack pointer
;set VESA graphic mode
mov ax, 0x4F02 ;set VBE
mov bx, 0x4103 ;set graphic mode 800x600 256 colours
int 0x10 ;start BIOS interrupt
;LOAD KERNEL
;reset floppy
mov ah, 0
mov dl, 0
int 13h ;call reset
;read floppy
mov ax, 1000h ;load kernel to 1000h
mov es, ax ;load kernel to 1000h
mov bx, 0 ;segment 0
mov ah, 0x02 ;read function
mov al, 100 ;100 sectors
mov ch, 1 ;track 1
mov cl, 2 ;start sector is 2
mov dh, 0 ;head 0
mov dl, 0 ;floppy A
int 13h ;call read
jmp load_gdt
;global descriptor table
gdt:
gdt_null:
dq 0
gdt_code:
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
gdt_data:
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_end:
gdt_desc:
db gdt_end - gdt
dw gdt
;load gdt
load_gdt:
cli
xor ax, ax
mov ds, ax
lgdt [gdt_desc]
;jump into protected mode
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 0x0008:clear_pipe
;NOW WE ARE IN PROTECTED MODE
bits 32
clear_pipe:
mov ax, 0x0010
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov esp, 090000h ;set stack pointer
;JUMP TO EXECUTE KERNEL!
jmp 0x1000:0x0
times 510-($-$$) db 0 ;Pad remainder of boot sector with 0s
dw 0xAA55 ;The standard PC boot signature