rdos/lib/print.asm

67 lines
949 B
NASM

; important functions in this file: kprintf
; write a character to kernel output
; in: al
printc:
push ax
push bx
mov bx, 0x0000
mov ah, 0x0e
int 0x10
pop bx
pop ax
ret
; prints a nibble in hex
; in: al
print4:
and al, 0x0F
add al, 0x30
cmp al, 0x3a
jl printc
add al, 0x07
jmp printc
; print a byte
; in: al
print8:
push ax ; avoid destroying ah
aam 16 ; high nibble moved into ah
xchg ah,al ; high nibble first
call print4
xchg ah,al
call print4
pop ax
ret
; print a word
; in: ax
print16:
xchg ah,al
call print8
xchg ah,al
call print8
ret
; print a inline following its call opcode
; the string ends with a nullbyte
; trashes si
print_inline:
pop si
push ax
push bx
mov bx, 0x0000
.loop:
lodsb
cmp al, 0x00
je .end
mov ah, 0x0e
int 0x10
cmp al, 0x0D
jmp .loop
.end:
pop bx
pop ax
push si
ret