Hi, I am trying to learn low-level development. By putting 0 in ebx and 1 in eax (for exit() syscall) and calling int 0x80, it should exit the program. I have a simple c program that runs fine, but when I paste this in, instead of exiting as expected, I get a segmantation fault. Why does this happen?
THANK YOU!
__asm__ ("xor %ebx, %ebx;"
"mov %al, 1;"
"int $80;"
);
edit: thanks for advice, still nothing but seg faults, though. here are modifications i've made:
__asm__ ("xor %ebx, %ebx;"
"xor %eax, %eax;"
"mov $1, %eax;"
"int $80;"
);
edit: after modifying this example from http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
asm("movl $1,%%eax; /* SYS_exit is 1 */
xorl %%ebx,%%ebx; /* Argument is in ebx, it is 0 */
int $0x80" /* Enter kernel mode */
);
This finally worked for me:
asm(" movl $1,%eax;
xorl %ebx,%ebx;
int $0x80
"
);
thanks for looking and offering advice.