From 1c4a0cf18543fbd002f4d1e8182ebf46a126bb5f Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Sun, 31 Mar 2019 12:22:42 +0000 Subject: [PATCH] lib/print: shave off some bytes --- lib/print.asm | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/lib/print.asm b/lib/print.asm index 82ac24b..4fa482e 100644 --- a/lib/print.asm +++ b/lib/print.asm @@ -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