i've tryied to create my own OS in assembly. i learned real mode (16 bit) and now i'm learning protected mode (32 bit)
in the QEMU emulator the OS works perfectly but when i load it on my computer (32 bit) it doesn't work.
this is the code:
[org 0x7c00]
xor ax, ax
mov ds, ax
mov es, ax
mov bp, 0x8000
mov sp, bp
mov ah, 0x0
mov al, 0x3
int 0x10
CODE_SEG equ GDT_code - GDT_start
DATA_SEG equ GDT_data - GDT_start
cli
lgdt [GDT_descriptor]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp CODE_SEG:start_protected_mode
;jmp $
GDT_start: ; must be at the end of real mode code
GDT_null:
dd 0x0
dd 0x0
GDT_code:
dw 0xffff
dw 0x0
db 0x0
db 0b10011010
db 0b11001111
db 0x0
GDT_data:
dw 0xffff
dw 0x0
db 0x0
db 0b10010010
db 0b11001111
db 0x0
GDT_end:
GDT_descriptor:
dw GDT_end - GDT_start - 1
dd GDT_start
[bits 32]
start_protected_mode:
mov ax, DATA_SEG
mov ss, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ebp, 0x90000
mov esp, ebp
mov al, 'A'
mov ah, byte 0x02
mov [0xb8000], ax
hlt
jmp $
times 510-($-$$) db 0
dw 0xaa55
and for the compilation I use these commands:
nasm -f bin bootloader.asm -o boot.bin
qemu-system-x86_64 boot.bin
where is the mistake?