1
0
tetros/bios/print.asm
Mark 711162f55b
Some checks failed
CI / Typos (push) Failing after 8s
CI / Build (push) Successful in 41s
CI / Clippy (push) Successful in 1m1s
Comments
2025-03-04 19:15:19 -08:00

69 lines
794 B
NASM

SECTION .text
USE16
; Print a string and a newline
;
; Clobbers ax
print_line:
mov al, 13
call print_char
mov al, 10
jmp print_char
; Print a string
;
; Input:
; si: points at zero-terminated String
;
; Clobbers si, ax
print:
pushf
cld
.loop:
lodsb
test al, al
jz .done
call print_char
jmp .loop
.done:
popf
ret
; Print a character
;
; Input:
; al: character to print
print_char:
pusha
mov bx, 7
mov ah, 0x0e
int 0x10
popa
ret
; print a number in hex
;
; Input:
; bx: the number
;
; Clobbers al, cx
print_hex:
mov cx, 4
.lp:
mov al, bh
shr al, 4
cmp al, 0xA
jb .below_0xA
add al, 'A' - 0xA - '0'
.below_0xA:
add al, '0'
call print_char
shl bx, 4
loop .lp
ret