Subject: Re: Direct syscall in asm
To: B. James Phillippe <bryan@darkforest.org>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: port-alpha
Date: 01/29/2002 17:49:55
<bryan@darkforest.org> (B. James Phillippe) writes:

> I'm attempting to overcome a long-time weakness with asm by coding up some
> examples, starting with "Hello World".  Most of the resources I find are
> for either x86, Linux or Microsoft/Intel-style asm.  I'd like to learn
> using NetBSD/alpha and GNU as, since that is what I use.  I have been
> reading the Alpha reference material and it appears I need to issue a
> call_pal with a value of 0x83 (for syscall).  If I'm understanding the
> material properly, I need to first push the arguments to the stack
> (including the system call number).  I guess I'm hoping someone here would
> be able to show a minimal example of how this is done under NetBSD.

This isn't right. The Alpha calling convention doesn't use the stack
until after the first six arguments have been passed in registers
A0-A5, and the system call number is passed in register V0. Unlike the
MIPS O32 convention, space isn't reserved on the stack for those
arguments, either.

Have a look at src/lib/libc/arch/alpha/SYS.h and
src/sys/arch/alpha/include/asm.h. It's also much more common to use
conventional register abbreviations - a0, a1, a2 - instead of $16,
$17, $18.

        - Nathan