broken print_uint

This commit is contained in:
maelstrom 2024-07-24 22:27:55 +03:00
parent 18591b2770
commit 8bd72097d5
4 changed files with 32 additions and 2 deletions

View file

@ -5,8 +5,8 @@
section KERNEL follows=BOOTSECTOR vstart=1000h section KERNEL follows=BOOTSECTOR vstart=1000h
main: main:
mov bx, HELLO_WORLD mov bx, 24734
call println call print_uint
jmp $ ; Halt jmp $ ; Halt

BIN
main.bin

Binary file not shown.

View file

@ -120,6 +120,33 @@ print_bin:
popa popa
ret ret
print_uint:
pusha
mov ax, bx ; Move number into ax
mov bx, _print_dec_buff+5 ; Place in the buffer
.loop:
sub bx, 1
mov cx, 10
mov dx, 0 ; IMPORTANT: Division will not work unless the remainder register is set to 0 beforehand
div cx ; Divide ax by cx (10), -> ax, rem -> dx
add dx, 0x30 ; Add ascii '0'
mov [bx], dx ; Place that value into the buffer
cmp ax, 0 ; Continue looping as long as the quotient is not 0
jnz .loop
; Print the contents of the buffer
; String is already in bx
call print
popa
ret
_print_dec_buff: resb 6
%macro print_ch 1 %macro print_ch 1
push ax push ax

3
ret_util.asm Normal file
View file

@ -0,0 +1,3 @@
%macro pushargs
%endmacro