I have the following assembly code. I'm trying to create a small bootloader to go into 32-bit protected mode. Once in protected mode, I need to print to VGA text mode video memory (0xb8000) for testing purposes. My code doesn't work. I found code from various resources around the web and learned that most have similar code which works properly, like this example: Printing characters to screen ASM in protected mode . My code that doesn't work:
bits 16
mov ah, 0x00 ;Set up video mode
mov al, 0x03
int 0x10
gdt_start:
dq 0x0
gdt_code:
dw 0xFFFF
dw 0x0
db 0x0
db 10011010b
db 11001111b
db 0x0
gdt_data:
dw 0xFFFF
dw 0x0
db 0x0
db 10010010b
db 11001111b
db 0x0
gdtr:
dw 24
dd gdt_start
lgdt [gdtr]
cli
mov eax, cr0
or al, 1
mov cr0, eax
jmp 0x08:protectedMode
bits 32
protectedMode:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov word [0xb8000], 0x0769
times 510 - ($-$$) db 0
dw 0xaa55
I compile the code with:
nasm -fbin boot.asm -oboot.bin
and run the result with:
qemu-system-x86_64 -fda boot.bin
It doesn't do anything.
When I disassemble the code with:
ndisasm boot.bin
it outputs the following result:
Why is the instruction before appending the zeroes
mov dword [di], 0xb8000
while it should be
mov word [0xb8000], 0x0769