I'm currently working on developing a simple operating system using a custom bootloader and kernel. However, when I boot my system, it only displays a cursor on the screen and doesn't show any further output. I'm looking for some guidance on how to troubleshoot this issue.
Here are some details about my setup:
I have a custom bootloader written in assembly (bootloader.asm) that loads the kernel into memory.
My kernel is written in assembly (kernel.asm) and contains basic initialization code.
I'm using NASM to assemble the code and LD to link the object files together.
I'm testing the OS on physical hardware.
I verified that the bootloader is loading the kernel into memory correctly by inspecting the memory contents at the designated location.
I added debug output statements in the bootloader and kernel code to check if they are executing as expected. However, I'm not seeing any output on the screen beyond the cursor.
I suspect there might be an issue with my code or configuration that prevents the operating system from properly initializing and displaying output on the screen.
Could someone guide me on how to further troubleshoot this issue and get my operating system to display the expected output?
Any insights, suggestions, or debugging techniques would be greatly appreciated.
Bootloader:
[BITS 16]
[ORG 0x7C00]
section bootloader
jmp main
main:
; Set up segment registers
mov ax, 0x07C0
mov ds, ax
mov es, ax
; Load the kernel into memory
mov bx, 0x8000 ; Destination memory address
mov ah, 0x02 ; Read sector function
mov al, 1 ; Number of sectors to read
mov dl, 0x80 ; Boot drive number
mov ch, 0 ; Cylinder number
mov dh, 0 ; Head number
mov cl, 2 ; Sector number
int 0x13 ; Disk interrupt
; Jump to the loaded kernel
jmp 0x8000:0000
times 510 - ($ - $$) db 0
dw 0xAA55 ; Boot signature
Kernel (I also decided to have a UI in the kernel):
[BITS 16]
[ORG 0x8000]
section kernel
start:
mov ax, 0x07C0 ; Set up segment registers
mov ds, ax
mov es, ax
; Clear the screen
mov ah, 0x00 ; Video BIOS - Set video mode
mov al, 0x03 ; Mode 3 (Text mode: 80x25, 16 colors)
int 0x10 ; Video interrupt
; Print the menu options
mov si, menu
call printString
; Wait for user input
call readChar
; Process user input
cmp al, '1'
je option1
cmp al, '2'
je option2
jmp invalidOption
option1:
mov si, msgOption1
call printString
jmp end
option2:
mov si, msgOption2
call printString
jmp end
invalidOption:
mov si, msgInvalid
call printString
end:
; Halt the system
cli
hlt
printString:
lodsb ; Load the next character from string
test al, al ; Check if end of string
jz done ; If yes, return
mov ah, 0x0E ; Video BIOS - Teletype output
mov bh, 0x00 ; Video page
int 0x10 ; Video interrupt
jmp printString ; Print next character
done:
ret
readChar:
mov ah, 0x00 ; BIOS - Wait for key press
int 0x16 ; Keyboard interrupt
ret
menu db 'Welcome to aiOS!', 0x0D, 0x0A, 'Select an option:', 0x0D, 0x0A, '1. Option 1', 0x0D, 0x0A, '2. Option 2', 0x0D, 0x0A, 0x00
msgOption1 db 'You selected Option 1.', 0x0D, 0x0A, 0x00
msgOption2 db 'You selected Option 2.', 0x0D, 0x0A, 0x00
msgInvalid db 'Invalid option.', 0x0D, 0x0A, 0x00
times 510 - ($ - $$) db 0
dw 0xAA55 ; Boot signature