Seg fault with inline ASM
Orginally the function was in it's own ASM file and was linking it in. But to make it a little easier to trouble shoot here I did it inline. The problem is that I get a seg fault on the exit of the program. I checked the frame pointer and stack pointer before and after the function and they are identical so my function isn't screwing that up.
Anyone have any ideas?
Code:
#include <stdio.h>
int func (int, int);
int main(void)
{
int x=5, y=10;
int z = func(x,y);
printf("%d\n", z);
return 0;
}
int func (int x, int y)
{
int ret;
asm("
pnum1 = 8
pnum2 = 12
lret = -4
movl pnum1(%ebp), %eax
movl pnum2(%ebp), %ebx
addl %ebx, %eax
movl %eax, lret(%ebp)
");
return ret;
}
Compiler: GCC
OS: Debian
Warnings: None