taytyypa-menna-nopeasti/debugpr.asm
2025-10-25 20:07:33 +03:00

67 lines
No EOL
671 B
NASM

BIOS_PRINT equ 0
%macro printreg 1
print %+ %1:
pusha
mov ah, 9
mov dx, .str
int 0x21
popa
push %1
pop ax
call print16
pusha
mov ah, 2
mov dl, ' '
int 0x21
popa
ret
section data
.str db %str(%1), '=$'
section code
%endmacro
printreg ax
printreg bx
printreg cx
printreg si
printreg di
printreg sp
printreg es
print16:
push ax
mov al, ah
call print8
pop ax
print8:
push ax
shr al, 4
call print4
pop ax
print4:
pusha
mov bx, hexdigits
and ax, 0xf
add bx, ax
%if BIOS_PRINT
mov al, [cs:bx]
mov ah, 0xe
int 0x10
%else
mov dl, [cs:bx]
mov ah, 2
int 0x21
%endif
popa
ret
section data
hexdigits db '0123456789abcdef'
section code