broken print_uint
This commit is contained in:
parent
18591b2770
commit
8bd72097d5
4 changed files with 32 additions and 2 deletions
4
main.asm
4
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
|
||||
|
||||
|
|
BIN
main.bin
BIN
main.bin
Binary file not shown.
|
@ -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
|
||||
|
|
3
ret_util.asm
Normal file
3
ret_util.asm
Normal file
|
@ -0,0 +1,3 @@
|
|||
%macro pushargs
|
||||
|
||||
%endmacro
|
Loading…
Add table
Reference in a new issue