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
|
section KERNEL follows=BOOTSECTOR vstart=1000h
|
||||||
|
|
||||||
main:
|
main:
|
||||||
mov bx, 24734
|
mov bx, 65535
|
||||||
call print_uint
|
call print_uint
|
||||||
|
|
||||||
jmp $ ; Halt
|
jmp $ ; Halt
|
||||||
|
|
BIN
main.bin
BIN
main.bin
Binary file not shown.
|
@ -124,24 +124,30 @@ print_uint:
|
||||||
pusha
|
pusha
|
||||||
|
|
||||||
mov ax, bx ; Move number into ax
|
mov ax, bx ; Move number into ax
|
||||||
|
mov bx, 0
|
||||||
mov bx, _print_dec_buff+5 ; Place in the buffer
|
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
sub bx, 1
|
|
||||||
mov cx, 10
|
mov cx, 10
|
||||||
mov dx, 0 ; IMPORTANT: Division will not work unless the remainder register is set to 0 beforehand
|
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
|
div cx ; Divide ax by cx (10), -> ax, rem -> dx
|
||||||
|
|
||||||
add dx, 0x30 ; Add ascii '0'
|
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
|
cmp ax, 0 ; Continue looping as long as the quotient is not 0
|
||||||
jnz .loop
|
jnz .loop
|
||||||
|
|
||||||
; Print the contents of the buffer
|
.print_loop:
|
||||||
; String is already in bx
|
sub bx, 1
|
||||||
call print
|
|
||||||
|
pop ax ; 16-bit value
|
||||||
|
mov ah, 0x0e
|
||||||
|
;add al, 0x30
|
||||||
|
int 0x10
|
||||||
|
|
||||||
|
cmp bx, 0
|
||||||
|
jnz .print_loop
|
||||||
|
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
Loading…
Add table
Reference in a new issue