Notes on assembler veneers
==========================

1. Saving on stack
------------------

The routine will need to save the link register (lr) on the stack at entry to
the function.  It will also need save all the 'variable' registers on the
stack that are used.  For example, if the routine used variable register 1
and variable register 2 (v1 and v2) for input (or output) then the following
would be required :-

	STMFD	sp!,{lr,v1,v2}
	.
	.
	.
	.
	LDMFD	sp!,{lr,v1,v2}
	
	

2. Loading args off stack
-------------------------

Arguments v1-v6 are stored on the stack.  The way they are loaded into
registers before the SWI is called is as follows (where N is the argument
number) :-

	LDR	vN,[sp,NumberRegsPutOnStack + (N * 4)]
	
for example :-

	STMFD	sp!,{lr,v1,v2}
	LDR	v1,[sp,#12]
	LDR	v2,[sp,#16]
	
	
3. Saving args (not on stack)
-----------------------------

For return arguments a1-a2 then stack access is not necessary.  The saving of
args after the SWI call is very simple.  For example, for saving argument 2
(a2) with the contents of R0, the store is done as follows :-

	TEQ	a2,#0
	STRNE	r0,[a2]
	
	
4. Saving args (when  on stack)
-------------------------------

For return arguments v1-v6, then the arguments are on the stack.  Hence, the
pointer argument will need to be loaded from the stack before a save can be
made. For example, for saving variable 1 (v1) with the contents of R0, the
store is done as follows :-

	LDR	lr,[sp,#8]
	TEQ	lr,#0
	STRNE	r0,[lr]
	
	
5. Routine exit
---------------

The way that a routine is exited depends on whether or not an error has
ocurred from the calling of the SWI.  The exit part of the routine will look
like the following :-

		SWI	Toolbox_ObjectMiscOp
		BVS	%F99
		.
		.
		.
		.
		.
		MOV	r0,#0
	99	LDMFD	sp!,{lr,.......}^
	