160484Sobrien/*	$NetBSD: saveregs.S,v 1.4 2003/08/07 16:42:23 agc Exp $	*/
289857Sobrien
360484Sobrien/*
460484Sobrien * Copyright (c) 1992, 1993
560484Sobrien *	The Regents of the University of California.  All rights reserved.
660484Sobrien *
760484Sobrien * This software was developed by the Computer Systems Engineering group
860484Sobrien * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
960484Sobrien * contributed to Berkeley.
1060484Sobrien *
1160484Sobrien * Redistribution and use in source and binary forms, with or without
1260484Sobrien * modification, are permitted provided that the following conditions
1360484Sobrien * are met:
1460484Sobrien * 1. Redistributions of source code must retain the above copyright
1560484Sobrien *    notice, this list of conditions and the following disclaimer.
1660484Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1760484Sobrien *    notice, this list of conditions and the following disclaimer in the
1860484Sobrien *    documentation and/or other materials provided with the distribution.
1960484Sobrien * 3. Neither the name of the University nor the names of its contributors
2060484Sobrien *    may be used to endorse or promote products derived from this software
2160484Sobrien *    without specific prior written permission.
2260484Sobrien *
2360484Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2460484Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2560484Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2660484Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2760484Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2860484Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2960484Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3060484Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3160484Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3260484Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3360484Sobrien * SUCH DAMAGE.
3460484Sobrien *
3560484Sobrien * from: Header: saveregs.s,v 1.1 91/07/06 17:22:33 torek Exp
3660484Sobrien */
3760484Sobrien
3860484Sobrien#include <machine/asm.h>
3960484Sobrien#if defined(LIBC_SCCS) && !defined(lint)
4060484Sobrien	RCSID("$NetBSD: saveregs.S,v 1.4 2003/08/07 16:42:23 agc Exp $")
4160484Sobrien#endif /* LIBC_SCCS and not lint */
4260484Sobrien
4360484Sobrien/*
4460484Sobrien * Save register arguments in caller's `arg dump' area, so that
4560484Sobrien * stdarg functions work.
4660484Sobrien *
4760484Sobrien * This really should be done with a pointer to the arg dump area;
4860484Sobrien * our caller should allocate that area, not our caller's caller.
4960484Sobrien * But then, they did not let me invent the calling sequence....
5060484Sobrien *
5160484Sobrien * We assume the caller has executed a `save' instruction.
5260484Sobrien */
5360484Sobrien
5460484SobrienENTRY(__builtin_saveregs)
5560484Sobrien	st	%i0, [%fp + 0x44]	! fr->fr_argd[0]
5660484Sobrien	st	%i1, [%fp + 0x48]	! fr->fr_argd[1]
5777298Sobrien	st	%i2, [%fp + 0x4c]	! fr->fr_argd[2]
5860484Sobrien	st	%i3, [%fp + 0x50]	! fr->fr_argd[3]
5960484Sobrien	st	%i4, [%fp + 0x54]	! fr->fr_argd[4]
6060484Sobrien	retl
6160484Sobrien	st	%i5, [%fp + 0x58]	! fr->fr_argd[5]
6277298Sobrien