Subject: SH3/4 function calling conventions
To: None <port-dreamcast@netbsd.org>
From: Christian Groessler <cpg@aladdin.de>
List: port-dreamcast
Date: 02/21/2003 23:16:37
Hi,

I'm currently digging a bit into assembly programming on the DC / SH.

Is there somewhere a documentation about the calling conventions used
on NetBSD (probably it's a gcc definition)?

Specifically I want to know
        - which registers are used for function parameters
        - which registers contain function return values
        - which registers need to be preserved across function calls


regards,
chris


PS: appended is my first SH assembly program :-)

-----------------------
SYS_exit	=	1
SYS_write	=	4

	.little

	.section ".note.netbsd.ident","a"
	.align 2

	.long 7
	.long 4
	.long 1			! ELF NOTE TYPE NETBSD TAG
	.ascii "NetBSD\0\0"
	.long 199905

# r4 - 1st parm
# r5 - 2nd parm
# r6 - 3rd parm

	.section	.rodata
message:
	.ascii	"Hello World from the Assembler Universe"
	.byte	10
mlen	=	. - message

	.text
	.align	2

.globl _start
_start:

	mov	#mlen,r6		! count
	mov.l	mptr,r5			! buf
	mov	#1,r4			! fd (stdout)
	mov	#SYS_write,r0		! syscall #
	trapa	#0x80
	nop

	mov	#42,r4			! return code
	mov	#SYS_exit,r0
	trapa	#0x80
	nop

mptr:	.long	message

-----------------------