uint printinggit add .!
This commit is contained in:
parent
8bd72097d5
commit
c9d26b0a4e
3 changed files with 14 additions and 8 deletions
2
main.asm
2
main.asm
|
@ -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
BIN
main.bin
Binary file not shown.
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue