2024-04-28 06:41:36 +00:00
|
|
|
bios_log_time:
|
|
|
|
clc
|
|
|
|
mov ah, 0x02
|
|
|
|
int 0x1A
|
|
|
|
|
2024-06-11 08:34:41 +00:00
|
|
|
; print hours
|
2024-04-28 06:41:36 +00:00
|
|
|
mov al, ch
|
2024-05-03 10:00:17 +00:00
|
|
|
mov ah, al
|
|
|
|
shr ah, 4
|
|
|
|
and ah, 0xF
|
|
|
|
and al, 0xF
|
2024-06-11 08:34:41 +00:00
|
|
|
|
2024-04-28 06:41:36 +00:00
|
|
|
add ah, 0x30
|
|
|
|
add al, 0x30
|
2024-06-11 08:34:41 +00:00
|
|
|
mov [szTime + 1], ah
|
|
|
|
mov [szTime + 2], al
|
2024-04-28 06:41:36 +00:00
|
|
|
|
2024-06-11 08:34:41 +00:00
|
|
|
; print minutes
|
2024-04-28 06:41:36 +00:00
|
|
|
mov al, cl
|
2024-05-03 10:00:17 +00:00
|
|
|
mov ah, al
|
|
|
|
shr ah, 4
|
|
|
|
and ah, 0xF
|
|
|
|
and al, 0xF
|
2024-06-11 08:34:41 +00:00
|
|
|
|
2024-04-28 06:41:36 +00:00
|
|
|
add ah, 0x30
|
|
|
|
add al, 0x30
|
2024-06-11 08:34:41 +00:00
|
|
|
mov [szTime + 4], ah
|
|
|
|
mov [szTime + 5], al
|
2024-04-28 06:41:36 +00:00
|
|
|
|
2024-06-11 08:34:41 +00:00
|
|
|
; print seconds
|
2024-04-28 06:41:36 +00:00
|
|
|
mov al, dh
|
2024-05-03 10:00:17 +00:00
|
|
|
mov ah, al
|
|
|
|
shr ah, 4
|
|
|
|
and ah, 0xF
|
|
|
|
and al, 0xF
|
2024-06-11 08:34:41 +00:00
|
|
|
|
2024-04-28 06:41:36 +00:00
|
|
|
add ah, 0x30
|
|
|
|
add al, 0x30
|
2024-06-11 08:34:41 +00:00
|
|
|
mov [szTime + 7], ah
|
|
|
|
mov [szTime + 8], al
|
2024-04-28 06:41:36 +00:00
|
|
|
|
2024-06-11 08:34:41 +00:00
|
|
|
push si
|
|
|
|
mov si, szTime
|
2024-04-28 06:41:36 +00:00
|
|
|
call bios_print
|
2024-06-11 08:34:41 +00:00
|
|
|
pop si
|
2024-04-28 06:41:36 +00:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
2024-06-12 11:53:51 +00:00
|
|
|
;; 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
|
|
|
|
|
2024-05-02 11:34:27 +00:00
|
|
|
;; Function: bios_log_hex
|
|
|
|
;;
|
2024-06-11 08:34:41 +00:00
|
|
|
;; Parameters:
|
|
|
|
;; EDI - number
|
2024-04-28 06:41:36 +00:00
|
|
|
bios_log_hex:
|
2024-06-11 08:34:41 +00:00
|
|
|
push si
|
|
|
|
mov si, szHexPrefix
|
2024-05-02 11:34:27 +00:00
|
|
|
call bios_print
|
2024-06-11 08:34:41 +00:00
|
|
|
pop si
|
2024-05-02 11:34:27 +00:00
|
|
|
|
|
|
|
or edi, edi
|
|
|
|
jz .print_zero
|
2024-06-11 08:34:41 +00:00
|
|
|
push si
|
2024-06-12 11:53:51 +00:00
|
|
|
mov si, szBuffer
|
2024-06-11 08:34:41 +00:00
|
|
|
xor cl, cl
|
2024-05-02 11:34:27 +00:00
|
|
|
.loop:
|
2024-06-11 08:34:41 +00:00
|
|
|
cmp cl, 8
|
|
|
|
je .print_number
|
2024-05-02 11:34:27 +00:00
|
|
|
rol edi, 4
|
|
|
|
mov eax, edi
|
|
|
|
and eax, 0xF
|
2024-06-11 08:34:41 +00:00
|
|
|
mov al, byte [sDigits + eax]
|
|
|
|
mov [si], al
|
|
|
|
inc si
|
|
|
|
inc cl
|
2024-05-02 11:34:27 +00:00
|
|
|
jmp .loop
|
|
|
|
.print_zero:
|
|
|
|
mov al, '0'
|
|
|
|
mov ah, 0x0E
|
|
|
|
int 0x10
|
|
|
|
jmp .end
|
|
|
|
.print_number:
|
2024-06-11 08:34:41 +00:00
|
|
|
mov [si], byte 0
|
2024-06-12 11:53:51 +00:00
|
|
|
mov si, szBuffer
|
2024-05-02 11:34:27 +00:00
|
|
|
call bios_print
|
2024-06-11 08:34:41 +00:00
|
|
|
pop si
|
2024-05-02 11:34:27 +00:00
|
|
|
.end:
|
2024-04-28 06:41:36 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
;; Function: bios_log
|
|
|
|
;;
|
|
|
|
;; Parameters:
|
|
|
|
;; SI - string to print
|
|
|
|
;; [STACK] - variadic arguments
|
|
|
|
;;
|
|
|
|
bios_log:
|
|
|
|
call bios_log_time
|
|
|
|
|
2024-05-02 11:34:27 +00:00
|
|
|
.loop:
|
|
|
|
mov al, [si]
|
|
|
|
or al, al
|
|
|
|
jz .end
|
|
|
|
cmp al, '%'
|
|
|
|
jne .putchar
|
|
|
|
inc si
|
|
|
|
mov al, [si]
|
|
|
|
cmp al, '%'
|
|
|
|
je .putchar
|
|
|
|
cmp al, 's'
|
|
|
|
jne .check_x
|
|
|
|
mov di, si
|
|
|
|
pop ax
|
|
|
|
pop si
|
|
|
|
push ax
|
2024-04-28 06:41:36 +00:00
|
|
|
call bios_print
|
2024-05-02 11:34:27 +00:00
|
|
|
mov si, di
|
|
|
|
jmp .next
|
|
|
|
.check_x:
|
|
|
|
cmp al, 'x'
|
2024-06-12 11:53:51 +00:00
|
|
|
jne .check_d
|
2024-05-02 11:34:27 +00:00
|
|
|
pop ax
|
2024-06-11 08:34:41 +00:00
|
|
|
pop dword edi
|
2024-05-02 11:34:27 +00:00
|
|
|
push ax
|
|
|
|
call bios_log_hex
|
|
|
|
jmp .next
|
2024-06-12 11:53:51 +00:00
|
|
|
.check_d:
|
|
|
|
cmp al, 'd'
|
|
|
|
jne .unknown_format
|
|
|
|
pop ax
|
|
|
|
pop word di
|
|
|
|
push ax
|
|
|
|
call bios_log_number
|
|
|
|
jmp .next
|
2024-05-02 11:34:27 +00:00
|
|
|
.unknown_format:
|
|
|
|
mov al, '?'
|
|
|
|
.putchar:
|
|
|
|
mov ah, 0x0E
|
|
|
|
int 0x10
|
|
|
|
.next:
|
|
|
|
inc si
|
|
|
|
jmp .loop
|
|
|
|
.end:
|
2024-06-11 08:34:41 +00:00
|
|
|
mov si, szEndLine
|
2024-04-28 06:41:36 +00:00
|
|
|
call bios_print
|
2024-05-02 11:34:27 +00:00
|
|
|
|
2024-04-28 06:41:36 +00:00
|
|
|
ret
|
|
|
|
|
2024-06-11 08:34:41 +00:00
|
|
|
|
|
|
|
szTime db '[00:00:00] ', 0
|
|
|
|
szHexPrefix db '0x', 0
|
|
|
|
sDigits db '0123456789ABCDEF'
|
|
|
|
szEndLine db CR, LF, 0
|
2024-06-12 11:53:51 +00:00
|
|
|
szBuffer db '00000000', 0
|