Consider this bit of code which is part of a kinda itoa procedure, only the string is reversed:
#get a number from a parameter, this bit is identical to functional bits getting chars and strings
movl (%esi), %eax
addl $4, %esi
#uses the %ecx-register for the string, adds a zero at the beginning for later reversal purposes
movl $0, %ecx
incl %ecx
#the actual procedure
loop:
cmpl $0, (%eax)
je done
cdq #is this really necessary? doesn't seem to make any difference atm
movl $10, %ebx # the divisor
idivl %ebx
addl $48, %edx
movb (%edx), %bl
movb %bl, (%ecx)
incl %ecx
jmp loop
ignoring the fact that it doesn't handle negative integers at the moment, I can't for the life of me see why this would be segfaulting...