26th July 05:43
Help translating Intel to AT&T
In my comments, I assume that OpenBSD works the same as FreeBSD.
Do you really need to allocate storage for this?
I do not think this is necessary; .comm and .lcomm automatically
use the bss section.
...lcomm might be better, unless you want buf to be globally visible.
%ebx now contains the address _start will return to.
%ebx now contains argc.
%ebx now contains argv, which is the name of the program being
Note that after these 3 pops, %esp is pointing where it ought not
point, and your program will die a horrible death when it ends.
No you do not; see above. And anyway, you do not want it in
%ebx. In BSD, arguments to syscalls are placed on the stack,
right to left, just as in C (because the kernel expects to be
called through a C function).
Should also be on the stack.
Because the kernel expects to be called through a C function, it
expects an address to be on the stack before the arguments.
Either put the int $0x80 behind a call, or push a random value on
to the stack before the int $0x80.
Assuming OpenBSD works the same as FreeBSD, the carry flag is set
when there is an error, and the error code is in %eax.
Similar problems exist in the remainder of your code.
Thomas M. Sommers -- firstname.lastname@example.org -- AB2SB