Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
.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