diff --git a/main.asm b/main.asm index bbbfc03..4897e56 100644 --- a/main.asm +++ b/main.asm @@ -5,8 +5,8 @@ section KERNEL follows=BOOTSECTOR vstart=1000h main: - mov bx, HELLO_WORLD - call println + mov bx, 24734 + call print_uint jmp $ ; Halt diff --git a/main.bin b/main.bin index fe4ae11..7530319 100644 Binary files a/main.bin and b/main.bin differ diff --git a/print_util.asm b/print_util.asm index 2f002db..42a37ab 100644 --- a/print_util.asm +++ b/print_util.asm @@ -120,6 +120,33 @@ print_bin: popa 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 push ax diff --git a/ret_util.asm b/ret_util.asm new file mode 100644 index 0000000..ad2fe5e --- /dev/null +++ b/ret_util.asm @@ -0,0 +1,3 @@ +%macro pushargs + +%endmacro \ No newline at end of file