Skip to content

Commit

Permalink
feat(boot/loader): add bios_log_number
Browse files Browse the repository at this point in the history
  • Loading branch information
d0p1s4m4 committed Jun 12, 2024
1 parent 33cb848 commit 8589a5c
Showing 1 changed file with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions boot/loader/logger.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,37 @@ bios_log_time:

ret

;; Function: bios_log_number
;;
;; Parameters:
;; DI - number
bios_log_number:
push dx
push bx
xor cx, cx
mov ax, di
mov bx, 10
.loop_calc:
xor dx, dx
div bx
push dx
inc cx
or ax, ax
jnz .loop_calc
.loop_print:
pop ax
add al, '0'
mov ah, 0x0E
int 0x10
dec cx

or cl, cl
jnz .loop_print
pop bx
pop dx
ret

;; Function: bios_log_hex
;;
;; Parameters:
Expand All @@ -59,7 +90,7 @@ bios_log_hex:
or edi, edi
jz .print_zero
push si
mov si, szHexBuffer
mov si, szBuffer
xor cl, cl
.loop:
cmp cl, 8
Expand All @@ -79,7 +110,7 @@ bios_log_hex:
jmp .end
.print_number:
mov [si], byte 0
mov si, szHexBuffer
mov si, szBuffer
call bios_print
pop si
.end:
Expand Down Expand Up @@ -115,12 +146,20 @@ bios_log:
jmp .next
.check_x:
cmp al, 'x'
jne .unknown_format
jne .check_d
pop ax
pop dword edi
push ax
call bios_log_hex
jmp .next
.check_d:
cmp al, 'd'
jne .unknown_format
pop ax
pop word di
push ax
call bios_log_number
jmp .next
.unknown_format:
mov al, '?'
.putchar:
Expand All @@ -139,5 +178,5 @@ bios_log:
szTime db '[00:00:00] ', 0
szHexPrefix db '0x', 0
sDigits db '0123456789ABCDEF'
szHexBuffer db '00000000', 0
szEndLine db CR, LF, 0
szBuffer db '00000000', 0

0 comments on commit 8589a5c

Please sign in to comment.