Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Mar 20th, 2005, 11:16 AM   #1
Arnvidr
Newbie
 
Join Date: Mar 2005
Posts: 2
Rep Power: 0 Arnvidr is on a distinguished road
Unhappy x86 assembly (segfault)

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...
Arnvidr is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:09 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC