X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=ld45_start_nothing;a=blobdiff_plain;f=src%2Fdbglog.asm;fp=src%2Fdbglog.asm;h=0753631119ccb51900de62ad5dab7d1acfe1e00c;hp=0000000000000000000000000000000000000000;hb=371bbe72cccdd5c40d5118bd0417fab062f3699a;hpb=0216fd8105a2b94aab6eb1c013c97882cacaf0c1 diff --git a/src/dbglog.asm b/src/dbglog.asm new file mode 100644 index 0000000..0753631 --- /dev/null +++ b/src/dbglog.asm @@ -0,0 +1,67 @@ +; vi:filetype=nasm ts=8 sts=8 sw=8: + section .text + + ; expects the address of a zero-terminated string in esi + global dbglog_str +dbglog_str: + mov al, [esi] + cmp al, 0 + jz .end + inc esi + call ser_putchar + jmp dbglog_str +.end: ret + + global dbglog_str_num +dbglog_str_num: + pusha + call dbglog_str + mov eax, [esp + 28] ; eax pushed by pusha + + mov esi, numbuf + 16 + mov byte [esi], 0 + mov ebx, 10 +.convloop: + xor edx, edx + div ebx + add dl, '0' + dec esi + mov [esi], dl + cmp eax, 0 + jnz .convloop + + call dbglog_str + popa + ret + + +UART_DATA equ 3f8h +UART_LSTAT equ 3fdh +LST_TREG_EMPTY equ 20h + +ser_putchar: + push edx + cmp al, 10 + jnz .notlf + push eax + mov al, 13 + call ser_putchar + pop eax + +.notlf: mov ah, al + ; wait until the transmit register is empty + mov dx, UART_LSTAT +.wait: in al, dx + and al, LST_TREG_EMPTY + jz .wait + mov dx, UART_DATA + mov al, ah + out dx, al + + pop edx + ret + + + + section .data +numbuf: times 16 db 0