Last active
November 10, 2020 14:57
-
-
Save sebbekarlsson/c7c948bb9ee11c6884cc17153fb7a3b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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