done with itoa function
This commit is contained in:
parent
285f77c4fe
commit
1a052f3a6c
2 changed files with 19 additions and 4 deletions
13
src/itoa.s
13
src/itoa.s
|
|
@ -13,24 +13,29 @@ itoa:
|
||||||
mov $numbers, %bx
|
mov $numbers, %bx
|
||||||
|
|
||||||
mov $(itoa_result + ITOA_BUFFER_SIZE - 1), %di
|
mov $(itoa_result + ITOA_BUFFER_SIZE - 1), %di
|
||||||
|
movb $0, (%di)
|
||||||
|
dec %di
|
||||||
std
|
std
|
||||||
.div:
|
.div:
|
||||||
divl %ecx
|
divl %ecx
|
||||||
or %eax, %eax
|
|
||||||
jz .end # we run out of numbers
|
|
||||||
|
|
||||||
# yep, we're using LUT for number -> character conversion since ASCII is a fuck
|
# yep, we're using LUT for number -> character conversion since ASCII is a fuck
|
||||||
push %eax
|
push %eax
|
||||||
add %bx, %ax
|
movb (%ebx,%edx,1), %al
|
||||||
stosb
|
stosb
|
||||||
pop %eax
|
pop %eax
|
||||||
|
|
||||||
jmp .div
|
xor %edx, %edx
|
||||||
|
|
||||||
|
or %eax, %eax
|
||||||
|
jnz .div
|
||||||
.end:
|
.end:
|
||||||
|
# we run out of numbers
|
||||||
cld
|
cld
|
||||||
|
|
||||||
# we return ptr to string, since we're pushing chars in reverse, therefore
|
# we return ptr to string, since we're pushing chars in reverse, therefore
|
||||||
# beginning of string will change
|
# beginning of string will change
|
||||||
|
inc %di
|
||||||
mov %di, %ax
|
mov %di, %ax
|
||||||
|
|
||||||
pop %bx
|
pop %bx
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,16 @@
|
||||||
|
|
||||||
mov %ax, %si
|
mov %ax, %si
|
||||||
call prints
|
call prints
|
||||||
|
|
||||||
|
mov $'\n', %al
|
||||||
|
call serial_putc
|
||||||
|
|
||||||
|
mov $691337, %eax
|
||||||
|
mov $10, %ecx
|
||||||
|
call itoa
|
||||||
|
|
||||||
|
mov %ax, %si
|
||||||
|
call prints
|
||||||
.halt:
|
.halt:
|
||||||
jmp .halt
|
jmp .halt
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue