use null-terminated strings for vga_println

main
pantonshire 1 year ago
parent bd3063a80d
commit e913eb04ae

@ -214,7 +214,6 @@ main:
call vga_clear call vga_clear
mov ax, msg_boot1_loaded mov ax, msg_boot1_loaded
mov cx, MSG_BOOT1_LOADED_LEN
call vga_println call vga_println
call test_a20 call test_a20
@ -308,12 +307,13 @@ vga_scroll:
fnret fnret
; Write one line to the VGA text buffer. ; Write one line to the VGA text buffer. The string should be null-terminated; we embrace the evil
; of null-termination so this function only takes one argument, so it's slightly less of a faff to
; call in most cases.
; Arguments: ; Arguments:
; - ax: pointer to the string to print ; - ax: pointer to the string to print, null-terminated
; - cx: string length
; Return: none ; Return: none
; Clobber: ax, cx ; Clobber: ax
vga_println: vga_println:
fnstart fnstart
push si push si
@ -327,25 +327,26 @@ vga_println:
.scroll_done: .scroll_done:
mov si, ax mov si, ax
mov ax, VGA_WIDTH
cmp cx, ax
cmova cx, ax
mov di, VGA_WIDTH * (VGA_HEIGHT - 1) * 2
xor dx, dx xor dx, dx
mov ax, [GLOBALS + TEXTBUF_LINE] mov ax, [GLOBALS + TEXTBUF_LINE]
mov di, VGA_WIDTH * 2 mov di, VGA_WIDTH * 2
mul di mul di
mov di, ax mov di, ax
mov ax, 0xb800 mov ax, 0xb800
mov es, ax mov es, ax
mov ah, [GLOBALS + VGA_COL + 1] mov ah, [GLOBALS + VGA_COL + 1]
mov dx, VGA_WIDTH
.loop: .loop:
or cx, cx test dx, dx
jz .done jz .done
dec dx
mov al, [si] mov al, [si]
test al, al
jz .done
mov es:[di], ax mov es:[di], ax
add di, 2 add di, 2
inc si inc si
@ -404,14 +405,10 @@ test_a20:
ret ret
msg_boot1_loaded db "boot1 loaded. hello!" msg_boot1_loaded db "boot1 loaded. hello!", 0
MSG_BOOT1_LOADED_LEN equ $ - msg_boot1_loaded msg_a20_enabled db "a20 enabled", 0
msg_a20_enabled db "a20 enabled" msg_a20_disabled db "a20 disabled", 0
MSG_A20_ENABLED_LEN equ $ - msg_a20_enabled msg_panic db "panic!", 0
msg_a20_disabled db "a20 disabled"
MSG_A20_DISABLED_LEN equ $ - msg_a20_disabled
msg_panic db "fuck"
MSG_PANIC_LEN equ $ - msg_panic
boot1_magic dd BOOT1_MAGIC boot1_magic dd BOOT1_MAGIC

Loading…
Cancel
Save