Skip to content

Instantly share code, notes, and snippets.

@sebbekarlsson
Last active November 10, 2020 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebbekarlsson/c7c948bb9ee11c6884cc17153fb7a3b3 to your computer and use it in GitHub Desktop.
Save sebbekarlsson/c7c948bb9ee11c6884cc17153fb7a3b3 to your computer and use it in GitHub Desktop.
.type itos, @function
itos:
pushl %ebp
movl %esp, %ebp
movl 8(%esp), %eax # number
movl $12, %edi
leal (%esp, %edi, 1), %ebx # buffer
movl $0, %edi # counter
movl $0, %esi
pushl $0x0
jmp itos_loop
itos_loop:
movl $0, %edx
movl $10, %ecx
div %ecx
addl $48, %edx
pushl %edx
test %eax, %eax
je itos_buffer_loop
inc %edi
jmp itos_loop
itos_buffer_loop:
popl %ecx
movb %cl, (%ebx, %esi, 1)
test %edi, %edi
je itos_end
dec %edi
inc %esi
jmp itos_buffer_loop
itos_end:
movl %ebx, %eax
movl %ebp, %esp
popl %ebp
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment