From c9d26b0a4e5a4240ba7f0467bbecafd18bc11f93 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Wed, 24 Jul 2024 22:31:11 +0300 Subject: [PATCH] uint printinggit add .! --- main.asm | 2 +- main.bin | Bin 721 -> 730 bytes print_util.asm | 20 +++++++++++++------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/main.asm b/main.asm index 4897e56..cc81c2a 100644 --- a/main.asm +++ b/main.asm @@ -5,7 +5,7 @@ section KERNEL follows=BOOTSECTOR vstart=1000h main: - mov bx, 24734 + mov bx, 65535 call print_uint jmp $ ; Halt diff --git a/main.bin b/main.bin index 7530319b183793a36179919373394c17839a9e81..d02d440d4e8fe50d20bfcf0022cf625f8f4ad912 100644 GIT binary patch delta 75 zcmcb}dW&@fBNNmA|C5=SX4^0@?BrtD#lZ0WWAh<{pytDj%|94Q-!#8wjM&0=R-pMe dL+R(l!wg{Hk(!f}ucJ_&UzC%gs9@#7003iN8@>Pl delta 45 zcmV+|0Mh^31*!GblfeQR Di~kbu diff --git a/print_util.asm b/print_util.asm index 42a37ab..b86f3ed 100644 --- a/print_util.asm +++ b/print_util.asm @@ -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