I've written some simple bootloader that works good in QEMU and I decided to try it on real machine. I copied image file to flash drive and tried to load from it. But for some reason I've been getting just black screen with cursor somewhere near the top left corner and it made me think that it might be some problem with displaying strings on the screen. To check that idea I wrote simplistic bootloader that shows a message "Loading Image " and checks whether IO extensions (int 13h ah=42) are supported.If it's supported shows the message "Extensions are here". So in qemu it works and I'm getting these two messages as expected. But on my computer instead of two lines I'm getting one line like this "LoaExtensions are here". To print message I use int 10h ah=0Eh I tried to set different video modes using ah=0 function of the int 10h but I've always got the same result. Could you please help me to understand what could be wrong? This is the code:
bits 16 ; we are in 16 bit real mode
org 0 ; we will set regisers later
start: jmp Main ; jump to start of bootloader
msgLoading db "Loading Image ", 0x0D, 0x0A, 0x00
msgSectorReadingError db "ERROR: Can't read sectors from disk",0x0D,0x0A, 0x00
msgExtNotSupported db "ERROR: BIOS doesn't support LBA",0x0D,0x0A, 0x00
msgErrWhileLoadingImage db "ERROR: Couldn't read seconday image",0x0D,0x0A, 0x00
msgExtSupported db "Extensions are here",0x0D,0x0A, 0x00
imgName db "STAGE2 SYS"
;************************************************;
;************************************************;
; Prints a string
; DS=>SI: 0 terminated string
;************************************************;
Print:
lodsb ; load next byte from string from SI to AL
or al, al ; Does AL=0?
jz PrintDone ; Yep, null terminator found-bail out
mov ah, 0xE ; Nope-Print the character
int 0x10
jmp Print ; Repeat until null terminator found
PrintDone:
ret ; we are done, so return
;************************************************;
; Set Video mode
;
;************************************************;
SetVideoMode:
mov ax,0x0002
int 0x10
ret
;***********************************************;
; Checks whether BIOS supports extensions
;************************************************;
CheckExtenstions:
xor ax,ax
mov ah,0x41
xor dx,dx
mov dl,BYTE[driveNumber]
mov bx,0x55AA
int 0x13
cmp bx,0xAA55
jnz .error
test cl,0x1
jz .error
jmp .exit
.error:
mov si,msgExtNotSupported
call Print
cli
hlt
.exit:
mov si,msgExtSupported
call Print
cli
hlt
ret
Main:
;----------------------------------------------------
; code located at 0000:7C00, adjust segment registers
;----------------------------------------------------
cli ; disable interrupts
mov ax, 0x07C0 ; setup registers to point to our segment
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
;----------------------------------------------------
; create stack
;----------------------------------------------------
mov ax, 0x0000 ; set the stack
mov ss, ax
mov sp, 0xFFFE
mov BYTE[driveNumber],dl
sti ; restore interrupts
call SetVideoMode
mov si, msgLoading ; Show Loading Message
call Print
call CheckExtenstions
cli
hlt
TIMES 510-($-$$) DB 0
DW 0xAA55