Strange behaviour in assembly language program
ari
edelkind-freebsd-hackers at episec.com
Tue Mar 2 12:15:54 PST 2004
dgw at liwest.at said this stuff:
> Finally I came up with the simplest ASM program that reproduces the error.
> Here it is:
>
> .text
> .global _start
> _start:
> pushl $0
> movl $1, %eax
> int $0x80
>
> I looked everywhere (Developer's handbook, Google, ...) to find the solution,
> but all resources I consulted tell me this is the right way to do it.
> This program, however, always exits with 1 regardless of the value I push.
The kernel expects the interrupt to take place from within a function.
Try:
.text
.global _start
_start:
pushl $8
movl $1, %eax
call doint
doint: int $0x80
Or, if you really want the program as simple as possible, you can push
0, eax, garbage, anything onto the stack in place of the return address:
.text
.global _start
_start:
pushl $8
pushl $0
movl $1, %eax
int $0x80
ari
More information about the freebsd-hackers
mailing list