Skip to content

Commit

Permalink
fix(itoa): handle zero correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ErrorNoInternet committed Aug 22, 2024
1 parent ed02e91 commit f0284a0
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions itoa.S
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
itoa:
mov rsi, 10

itoa_loop:
itoa_convert:
xor rdx, rdx
div rbx
add rdx, '0'
dec rsi
mov [rdi + rsi], dl
test rax, rax
jne itoa_convert

itoa_done:
mov rcx, 10
sub rcx, rsi
ret

itoa_convert:
xor rdx, rdx
div rbx
add rdx, '0'
dec rsi
mov [rdi + rsi], dl
jmp itoa_loop

0 comments on commit f0284a0

Please sign in to comment.