QEMU giving blank output even though VGA memory is initialized

Viewed 244

I'm learning to write my own Operating System from this wonderful text (https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf). I'm facing a weird problem upon entering 32 bit protected mode from 16 bit real mode. The code i've written is supposed to output a sentence while in 16 bit mode (using interrupts) and output a sentence again after entering 32 bit mode (by initializing the VGA memory). However, only the first sentence gets printed in qemu for some reason. Here is the relevant segments of the code:

The main boot sector code

[org 0x7c00]

    mov bp, 0x9000
    mov sp, bp

    mov bx, MSG_REAL_MODE
    call print_string
    call print_newline

    call switch_to_pm

    jmp $

    %include "print_string.asm"
    %include "gdt.asm"
    %include "print_string_pm.asm"
    %include "switch_to_pm.asm"

[bits 32]

    BEGIN_PM:

        mov ebx, MSG_PROT_MODE
        call print_string_pm

        jmp $

    MSG_REAL_MODE db "Started in 16-bit Real Mode", 0
    MSG_PROT_MODE db "Loaded 32-bit Protected Mode", 0

    times 510-($-$$) db 0
    dw 0xaa55

The 32 bit print function

[bits 32]

VIDEO_MEMORY equ 0xb8000
WHITE_ON_BLACK equ 0x0f

print_string_pm:
    pusha
    mov edx, VIDEO_MEMORY

print_string_pm_loop:
    mov al, [ebx]
    mov ah, WHITE_ON_BLACK

    cmp al, 0
    je print_string_pm_done

    mov [edx], ax

    add ebx, 1
    add edx, 2

    jmp print_string_pm_loop

print_string_pm_done:
    popa
    ret

The text to be printed in 32 bit mode has been stored in the register ebx.

0 Answers
Related