11.9Stsutsui/*	$NetBSD: printf.S,v 1.9 2011/03/26 15:49:26 tsutsui Exp $	*/
21.1Ssimonb
31.1Ssimonb/*-
41.1Ssimonb * Copyright (c) 1999 The NetBSD Foundation, Inc.
51.1Ssimonb * All rights reserved.
61.3Ssimonb *
71.3Ssimonb * This code is derived from software contributed to The NetBSD Foundation
81.3Ssimonb * by Jonathan Stone, Michael Hitch and Simon Burge.
91.1Ssimonb *
101.1Ssimonb * Redistribution and use in source and binary forms, with or without
111.1Ssimonb * modification, are permitted provided that the following conditions
121.1Ssimonb * are met:
131.1Ssimonb * 1. Redistributions of source code must retain the above copyright
141.1Ssimonb *    notice, this list of conditions and the following disclaimer.
151.1Ssimonb * 2. Redistributions in binary form must reproduce the above copyright
161.1Ssimonb *    notice, this list of conditions and the following disclaimer in the
171.1Ssimonb *    documentation and/or other materials provided with the distribution.
181.1Ssimonb *
191.1Ssimonb * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.1Ssimonb * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.1Ssimonb * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.1Ssimonb * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.1Ssimonb * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.1Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.1Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.1Ssimonb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.1Ssimonb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.1Ssimonb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.1Ssimonb * POSSIBILITY OF SUCH DAMAGE.
301.1Ssimonb */
311.1Ssimonb
321.1Ssimonb#include <mips/asm.h>
331.1Ssimonb#include <mips/cpuregs.h>
341.1Ssimonb#include <machine/dec_prom.h>
351.1Ssimonb
361.9Stsutsui	.set	reorder		# make as(1) handle hazard and BDslot
371.1SsimonbLEAF(printf)
381.1Ssimonb	lw	v0, _C_LABEL(callv)	# get pointer to call back vectors
391.6Smatt	lw	t9, 0x30(v0)	# offset for callv->_printf
401.6Smatt#ifdef __mips_n32
411.6Smatt	/*
421.6Smatt	 * If someone calls printf with more than 4 args on n32,
431.6Smatt	 * we need to synthesize a o32 call.  For now we assume no more than
441.6Smatt	 * 8 arguments and no 64bit values.
451.6Smatt	 */
461.6Smatt	subu	sp, sp,	48
471.6Smatt	sw	a4, 16(sp)
481.6Smatt	sw	a5, 20(sp)
491.6Smatt	sw	a6, 24(sp)
501.6Smatt	sw	a7, 28(sp)
511.6Smatt	sw	ra, 44(sp)
521.6Smatt	jalr	t9		# call PROM printf
531.6Smatt	lw	ra, 44(sp)
541.9Stsutsui	addu	sp, sp, 48
551.6Smatt	j	ra
561.6Smatt#else
571.6Smatt	j	t9		# call PROM printf
581.6Smatt#endif
591.1SsimonbEND(printf)
60