Slight speedup in itoa
This commit is contained in:
parent
d45f882710
commit
ffface8b0a
@ -1,13 +1,7 @@
|
|||||||
;; rax contains the integer
|
;; rax contains the integer
|
||||||
;; rbx contains a pointer to the string buffer
|
;; rbx contains a pointer to the string buffer
|
||||||
itoa:
|
itoa:
|
||||||
;; Fill 6 digits with zeroes
|
|
||||||
mov byte [rbx], '0'
|
mov byte [rbx], '0'
|
||||||
mov byte [rbx + 1], '0'
|
|
||||||
mov byte [rbx + 2], '0'
|
|
||||||
mov byte [rbx + 3], '0'
|
|
||||||
mov byte [rbx + 4], '0'
|
|
||||||
mov byte [rbx + 5], '0'
|
|
||||||
|
|
||||||
;; Special case for the number '0'
|
;; Special case for the number '0'
|
||||||
cmp rax, 0
|
cmp rax, 0
|
||||||
@ -16,6 +10,13 @@ itoa:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.not_zero:
|
.not_zero:
|
||||||
|
;; Fill 6 digits with zeroes
|
||||||
|
mov byte [rbx + 1], '0'
|
||||||
|
mov byte [rbx + 2], '0'
|
||||||
|
mov byte [rbx + 3], '0'
|
||||||
|
mov byte [rbx + 4], '0'
|
||||||
|
mov byte [rbx + 5], '0'
|
||||||
|
|
||||||
sub rax, 100000
|
sub rax, 100000
|
||||||
inc byte [rbx]
|
inc byte [rbx]
|
||||||
cmp rax, 0
|
cmp rax, 0
|
||||||
|
Loading…
Reference in New Issue
Block a user