done with itoa function

This commit is contained in:
mykola2312 2024-08-04 19:50:13 +03:00
parent 285f77c4fe
commit 1a052f3a6c
2 changed files with 19 additions and 4 deletions

View file

@ -13,24 +13,29 @@ itoa:
mov $numbers, %bx
mov $(itoa_result + ITOA_BUFFER_SIZE - 1), %di
movb $0, (%di)
dec %di
std
.div:
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
push %eax
add %bx, %ax
movb (%ebx,%edx,1), %al
stosb
pop %eax
jmp .div
xor %edx, %edx
or %eax, %eax
jnz .div
.end:
# we run out of numbers
cld
# we return ptr to string, since we're pushing chars in reverse, therefore
# beginning of string will change
inc %di
mov %di, %ax
pop %bx

View file

@ -43,6 +43,16 @@
mov %ax, %si
call prints
mov $'\n', %al
call serial_putc
mov $691337, %eax
mov $10, %ecx
call itoa
mov %ax, %si
call prints
.halt:
jmp .halt