In assembler:
.globl _test
_test:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
pushl %eax
call printf
popl %ebp
ret
Calling from c
main()
{
_test("Hello");
}
Compile:
gcc -m32 -o test test.c test.s
This code gives me illegal instruction sometimes and segment fault other times. In gdc i always get illegal instruction, this is just a simple test, i had a larger program that was working and suddenly after no apperant reason stopped working, now i always get this error even if i start from scratch like above.
I have narrowed it down to pushl %eax & call printf, if i comment out those lines the code runs fine.
Any ideas? (I'm running the program at my universities linux cluster, so I have not changed any settings..)