On May 2, 2008, at 6:14 AM, Anant Narayanan wrote:
Hi,
Is there a tool available which can convert plan 9 a.out executables
to plan 9 assembly code? I'd like to know how the C compiler stores
arguments for a system call on the stack for x86.
8c -S does not help, since all it displays is: `call print', instead
of what instructions are actually executed when print is called.
Regards,
Anant
8c doesn't use push or pop. It stores values directly onto the stack
with MOVL AX, 4(SP) for the second argument. This implies you'll need
to allocate enough stack space:
TEXT x, 0, $12
will give you enough for 2 arguments (don't tell me why not 3).
The compilers push arguments left to right every 4 bytes.