11.10Schristos/* $NetBSD: printf.s,v 1.10 2014/03/26 08:19:44 christos Exp $ */
21.2Sis
31.2Sis/*-
41.7Sis * Copyright (c) 1996,2006 The NetBSD Foundation, Inc.
51.2Sis * All rights reserved.
61.1Sis *
71.2Sis * This code is derived from software contributed to The NetBSD Foundation
81.2Sis * by Ignatios Souvatzis.
91.1Sis *
101.1Sis * Redistribution and use in source and binary forms, with or without
111.1Sis * modification, are permitted provided that the following conditions
121.1Sis * are met:
131.1Sis * 1. Redistributions of source code must retain the above copyright
141.1Sis *    notice, this list of conditions and the following disclaimer.
151.1Sis * 2. Redistributions in binary form must reproduce the above copyright
161.1Sis *    notice, this list of conditions and the following disclaimer in the
171.1Sis *    documentation and/or other materials provided with the distribution.
181.1Sis *
191.2Sis * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.2Sis * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.2Sis * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.2Sis * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.2Sis * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.2Sis * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.2Sis * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.2Sis * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.2Sis * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.2Sis * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.2Sis * POSSIBILITY OF SUCH DAMAGE.
301.1Sis */
311.1Sis
321.1Sis/*
331.1Sis * printf calling exec's RawDoFmt
341.1Sis * Beware! You have to explicitly use %ld etc. for 32bit integers!
351.1Sis */
361.4Sis#include <machine/asm.h>
371.1Sis	.text
381.4Sis	.even
391.1SisLputch:
401.6Smhitch	movl	%d0,%sp@-
411.4Sis	bsr	_C_LABEL(putchar)
421.5Sis	addql	#4,%sp
431.1Sis	rts
441.1Sis
451.4SisENTRY_NOPROFILE(printf)
461.5Sis	movml	#0x0032,%sp@-
471.5Sis	lea	%pc@(Lputch:w),%a2
481.5Sis	lea	%sp@(20),%a1
491.5Sis	movl	%sp@(16),%a0
501.5Sis	movl	%pc@(_C_LABEL(SysBase):w),%a6
511.5Sis	jsr	%a6@(-0x20a)
521.5Sis	movml	%sp@+, #0x4c00
531.1Sis	rts
541.7Sis
551.1SisLstorech:
561.5Sis	movb	%d0, %a3@+
571.1Sis	rts
581.1Sis
591.9Schristos#ifdef notdef
601.10SchristosENTRY_NOPROFILE(unused_sprintf)
611.5Sis	movml	#0x0032,%sp@-
621.5Sis	movl	%sp@(16),%a3
631.5Sis	lea	%pc@(Lstorech:w),%a2
641.5Sis	lea	%sp@(24),%a1
651.5Sis	movl	%sp@(20),%a0
661.5Sis	movl	%pc@(_C_LABEL(SysBase):w),%a6
671.5Sis	jsr	%a6@(-0x20a)
681.5Sis	movml	%sp@+, #0x4c00
691.1Sis	rts
701.9Schristos#endif
711.7Sis
721.7Sis/*
731.7Sis * XXX cheating - at least for now.
741.7Sis */
751.7SisENTRY_NOPROFILE(snprintf)
761.7Sis	movml	#0x0032,%sp@-
771.7Sis	movl	%sp@(16),%a3
781.7Sis	lea	%pc@(Lstorech:w),%a2
791.7Sis	lea	%sp@(28),%a1
801.7Sis	movl	%sp@(24),%a0
811.7Sis	movl	%pc@(_C_LABEL(SysBase):w),%a6
821.7Sis	jsr	%a6@(-0x20a)
831.7Sis	movml	%sp@+, #0x4c00
841.7Sis	rts
85