Subject: Re: atomic write routine
To: Jonathan Cline <>
From: Ben Harris <>
List: port-arm
Date: 05/17/2003 13:54:07
On Fri, 16 May 2003, Jonathan Cline wrote:

> Question ahead of time: what regs are
> available for use when calling asm from C?
> I've guessed that args are passed in r0..rN
> respectively.  In SetSYSCON below, I'm clobbering
> r3, r4, r5.  What's the c-model to save them?

NetBSD currently more-or-less follows the old ARM Procedure Call Standard
(APCS), in 32-bit mode (even on 26-bit CPUs) with no floating point and an
implicit stack limit.  When ARM finally complete their EABI (which was
called EABI-2001 until that started to be embarassing), we'll probably
follow that.  Anyway, the short answer to your question is:

R0-R3: argument passing/caller-saved
R4-R10: callee-saved
R12, R14: caller-saved
R11: frame pointer
R13: stack pointer

The usual idiom for creating a stack frame is:

	mov	ip, sp
	stmfd	sp!, {r4-r10, fp, ip, lr, pc}
	sub	fp, ip, #4

And to return:

	ldmdb	fp, {r4-r10, fp, sp, pc}

Replace "r4-r10" with something appropriate to your function.

Ben Harris                                                   <>
Portmaster, NetBSD/acorn26           <URL:>