uint printinggit add .!

This commit is contained in:
maelstrom 2024-07-24 22:31:11 +03:00
parent 8bd72097d5
commit c9d26b0a4e
3 changed files with 14 additions and 8 deletions

View file

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

BIN
main.bin

Binary file not shown.

View file

@ -124,24 +124,30 @@ print_uint:
pusha
mov ax, bx ; Move number into ax
mov bx, _print_dec_buff+5 ; Place in the buffer
mov bx, 0
.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
push dx ; Push that value
add bx, 1
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
.print_loop:
sub bx, 1
pop ax ; 16-bit value
mov ah, 0x0e
;add al, 0x30
int 0x10
cmp bx, 0
jnz .print_loop
popa
ret