Bootloader.asm
Code: Select all
[bits 16]
;----------Initialize Segments and Stack----------;
cli
mov ax, 0x7c0
mov ds, ax
mov ss, ax
xor ax, ax
mov es, ax
mov bp, ax
mov sp, ax
mov fs, ax
mov gs, ax
sti
;----------Initialize Segments and Stack----------;
;Load GDT.
call load_gdt
;Enable it.
mov eax, cr0
or eax, 0x1
mov cr0, eax
;Far jump to the 32bit code.
jmp load_gdt_cs:main_32
[bits 32]
main_32:
;----------Initialize Segments and Stack----------;
mov ax, load_gdt_ds
mov ds, ax
mov ss, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax, 0x90000
mov ebp, eax
mov esp, eax
;----------Initialize Segments and Stack----------;
mov ah, 'X'
mov al, 0x0b
mov [0xb8000], ax
jmp $
[bits 16]
;%include "include/print_static.asm"
;%include "include/print_hex.asm"
%include "include/load_gdt.asm"
hello: db "Hello Os!", 0x0
times 510 - ($-$$) db 0x0000
dw 0xAA55
load_gdt.asm:
Code: Select all
load_gdt_start:
load_gdt_start_null_segment:
dd 0x0
dd 0x0
load_gdt_start_code_segment:
dw 0xffff
dw 0x0000
db 0x00
db 10011010b
db 11001111b
db 0x00
load_gdt_start_data_segment:
dw 0xffff
dw 0x0000
db 0x00
db 10010010b
db 11001111b
db 0x00
load_gdt_end:
load_gdt_start_discriptor:
dw load_gdt_end - load_gdt_start - 1
dd load_gdt_start
load_gdt_cs: equ load_gdt_start_code_segment - load_gdt_start
load_gdt_ds: equ load_gdt_start_data_segment - load_gdt_start
load_gdt:
pusha
cli
lgdt [load_gdt_start_discriptor]
sti
popa
ret
What am I doing wrong?
Thank you.