lib/print: shave off some bytes

This commit is contained in:
Nero 2019-03-31 12:22:42 +00:00
parent 9aa032a90c
commit 1c4a0cf185
1 changed files with 18 additions and 27 deletions

View File

@ -1,37 +1,28 @@
; 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
push bx
mov bx, 0x0000
aam 16 ; high nibble moved into ah, low nibble into al
add ax, 0x3030
push ax
xchg al, ah
call .nib
pop ax
call .nib
pop bx
pop ax
ret
.nib:
cmp al, 0x3a
jl .out
add al, 0x07
.out:
mov ah, 0x0e
int 0x10
ret
; print a word