Click to See Complete Forum and Search --> : ASM help
CrowbarOfDeath
10-25-2001, 09:48 PM
For some reason I get a segmentation fault whenever I try to use strings in assembly. I even got the error when I did just this:
main() {
__asm__("
.string \"foo\"
");
}
I'm using GCC 3.0.1 to compile this and I just don't understand why it's doing this. Any suggestions?
-Thanks
Danger Fan
10-26-2001, 01:13 PM
Originally posted by CrowbarOfDeath:
<STRONG>For some reason I get a segmentation fault whenever I try to use strings in assembly. I even got the error when I did just this:
main() {
__asm__("
.string \"foo\"
");
}
I'm using GCC 3.0.1 to compile this and I just don't understand why it's doing this. Any suggestions?
-Thanks</STRONG>
well, considering I haven't used ASM in ages, nor do I remember much about it, I'm gonna give it a shot. No one else has responded yet, so here we go.
<long shot>
do you have to move the stack? does a string require you to add each character to the stack before you do anything with it? </long shot>
bwkaz
10-26-2001, 05:03 PM
Is it maybe putting the "foo" into memory at the current instruction pointer spot, or something? "Is it trying to execute your data?", is what I'm trying to ask.
Try putting a label after the .string line, and a jump to that label before it.
I believe you can use local variables in inline assembly, too (though maybe not with gcc -- I know you could with Borland Turbo C, but that was a while ago, and for DOS). You could try putting all your data in local variables, outside the ASM section.