os01
os01 copied to clipboard
String writing does not appear to be working
The code used to write a string, exercise 7.5.1, does not appear to be working. Specifically the string is not written to screen, even though multiple manual calls to my PutChar implementation do work. Even not the reference implementation was able to write the string to the display. Stripped down code:
bits 16
start: jmp boot
boot:
cli ; no interrupts
cld ; all that we need to init
call PrintBootMsg
hlt ; halt the system
; dl = x; dh = y
MovCursor:
; [redacted]
ret
; al = chr, cx = repeat
PutChar:
; [...] (redacted, is functional though)
ret
;; ds:si = Zero terminated string
Print:
.loop:
lodsb
or al, al
jz .done
mov cx, 1
call PutChar
jmp .loop
.done:
ret
; Print the boot message
PrintBootMsg:
; Reset cursor
mov bh, 0
mov bl, 0
call MovCursor
; Print
mov si, bootMsg
call Print
ret
;; constant and variable definitions
bootMsg db "Booting the Operating System!", 10, 13, 0
cursor_X db 0
cursor_Y db 0
; We have to be 512 bytes. Clear the rest of the bytes with 0
times 510 - ($-$$) db 0
dw 0xAA55 ; Boot Signature
The string does appear to be compiled in the binary, but not loading in memory. I tried inspecting the system memory with gdb x/512sb but I couldn't find any trace of the string. Moving the db instructions above does have effect on the output file but not on actual program execution.
Using NASM version 2.10.09.
Based on on another hello world example it appears a org x7c00 instruction needs to be present
Hmm it's true. 0x7c00 is in my linker script though. Probably I forgot to add it.
Ah, I see it now. However, that linker script is introduced after the first exercise.
Yes, I will need to update the book. Thanks for the report.