;; rax contains the integer ;; rbx contains a pointer to the string buffer itoa: 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' sub rax, 100000 inc byte [rbx] cmp rax, 0 jge itoa add rax, 100000 dec byte [rbx] .ten_thousand: sub rax, 10000 inc byte [rbx + 1] cmp rax, 0 jge .ten_thousand add rax, 10000 dec byte [rbx + 1] .one_thousand: sub rax, 1000 inc byte [rbx + 2] cmp rax, 0 jge .one_thousand add rax, 1000 dec byte [rbx + 2] .one_hundred: sub rax, 100 inc byte [rbx + 3] cmp rax, 0 jge .one_hundred add rax, 100 dec byte [rbx + 3] .ten: sub rax, 10 inc byte [rbx + 4] cmp rax, 0 jge .ten add rax, 10 dec byte [rbx + 4] add [rbx + 5], rax ret