asm.h revision 1.13
11.13Sjonathan/*	$NetBSD: asm.h,v 1.13 1997/07/20 09:47:03 jonathan Exp $	*/
21.4Scgd
31.1Sderaadt/*
41.2Sglass * Copyright (c) 1992, 1993
51.2Sglass *	The Regents of the University of California.  All rights reserved.
61.1Sderaadt *
71.1Sderaadt * This code is derived from software contributed to Berkeley by
81.1Sderaadt * Ralph Campbell.
91.1Sderaadt *
101.1Sderaadt * Redistribution and use in source and binary forms, with or without
111.1Sderaadt * modification, are permitted provided that the following conditions
121.1Sderaadt * are met:
131.1Sderaadt * 1. Redistributions of source code must retain the above copyright
141.1Sderaadt *    notice, this list of conditions and the following disclaimer.
151.1Sderaadt * 2. Redistributions in binary form must reproduce the above copyright
161.1Sderaadt *    notice, this list of conditions and the following disclaimer in the
171.1Sderaadt *    documentation and/or other materials provided with the distribution.
181.1Sderaadt * 3. All advertising materials mentioning features or use of this software
191.1Sderaadt *    must display the following acknowledgement:
201.1Sderaadt *	This product includes software developed by the University of
211.1Sderaadt *	California, Berkeley and its contributors.
221.1Sderaadt * 4. Neither the name of the University nor the names of its contributors
231.1Sderaadt *    may be used to endorse or promote products derived from this software
241.1Sderaadt *    without specific prior written permission.
251.1Sderaadt *
261.1Sderaadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271.1Sderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281.1Sderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291.1Sderaadt * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301.1Sderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311.1Sderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321.1Sderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331.1Sderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341.1Sderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351.1Sderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361.1Sderaadt * SUCH DAMAGE.
371.1Sderaadt *
381.4Scgd *	@(#)machAsmDefs.h	8.1 (Berkeley) 6/10/93
391.1Sderaadt */
401.1Sderaadt
411.1Sderaadt/*
421.1Sderaadt * machAsmDefs.h --
431.1Sderaadt *
441.1Sderaadt *	Macros used when writing assembler programs.
451.1Sderaadt *
461.1Sderaadt *	Copyright (C) 1989 Digital Equipment Corporation.
471.1Sderaadt *	Permission to use, copy, modify, and distribute this software and
481.1Sderaadt *	its documentation for any purpose and without fee is hereby granted,
491.1Sderaadt *	provided that the above copyright notice appears in all copies.
501.1Sderaadt *	Digital Equipment Corporation makes no representations about the
511.1Sderaadt *	suitability of this software for any purpose.  It is provided "as is"
521.1Sderaadt *	without express or implied warranty.
531.1Sderaadt *
541.1Sderaadt * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h,
551.2Sglass *	v 1.2 89/08/15 18:28:24 rab Exp  SPRITE (DECWRL)
561.1Sderaadt */
571.1Sderaadt
581.8Sjonathan#ifndef _MIPS_ASM_H
591.8Sjonathan#define _MIPS_ASM_H
601.1Sderaadt
611.1Sderaadt#include <machine/regdef.h>
621.1Sderaadt
631.1Sderaadt/*
641.1Sderaadt * Define -pg profile entry code.
651.13Sjonathan * XXX assume .set noreorder for kernel, .set reorder for user code.
661.1Sderaadt */
671.13Sjonathan#define _KERN_MCOUNT \
681.13Sjonathan	.set noat; \
691.13Sjonathan	move $1,$31; \
701.13Sjonathan	jal _mcount; \
711.13Sjonathan	subu sp,sp,8; \
721.13Sjonathan	.set at;
731.13Sjonathan
741.13Sjonathan
751.11Sjtc#ifdef GPROF
761.13Sjonathan# if defined(_KERNEL) || defined(_LOCORE)
771.13Sjonathan#  define MCOUNT _KERN_MCOUNT
781.13Sjonathan# else
791.13Sjonathan#  define MCOUNT .set noreorder; _KERN_MCOUNT ;  .set reorder;
801.13Sjonathan# endif
811.1Sderaadt#else
821.1Sderaadt#define	MCOUNT
831.2Sglass#endif
841.1Sderaadt
851.7Smellon#ifdef __NO_LEADING_UNDERSCORES__
861.6Smycroft# define _C_LABEL(x)	x
871.6Smycroft#else
881.6Smycroft# ifdef __STDC__
891.6Smycroft#  define _C_LABEL(x)	_ ## x
901.6Smycroft# else
911.6Smycroft#  define _C_LABEL(x)	_/**/x
921.6Smycroft# endif
931.6Smycroft#endif
941.6Smycroft
951.1Sderaadt/*
961.1Sderaadt * LEAF(x)
971.1Sderaadt *
981.1Sderaadt *	Declare a leaf routine.
991.1Sderaadt */
1001.1Sderaadt#define LEAF(x) \
1011.6Smycroft	.globl _C_LABEL(x); \
1021.6Smycroft	.ent _C_LABEL(x), 0; \
1031.6Smycroft_C_LABEL(x): ; \
1041.1Sderaadt	.frame sp, 0, ra; \
1051.1Sderaadt	MCOUNT
1061.1Sderaadt
1071.1Sderaadt/*
1081.1Sderaadt * NLEAF(x)
1091.1Sderaadt *
1101.1Sderaadt *	Declare a non-profiled leaf routine.
1111.1Sderaadt */
1121.1Sderaadt#define NLEAF(x) \
1131.6Smycroft	.globl _C_LABEL(x); \
1141.6Smycroft	.ent _C_LABEL(x), 0; \
1151.6Smycroft_C_LABEL(x): ; \
1161.1Sderaadt	.frame sp, 0, ra
1171.1Sderaadt
1181.1Sderaadt/*
1191.1Sderaadt * ALEAF -- declare alternate entry to a leaf routine.
1201.1Sderaadt */
1211.7Smellon#ifdef USE_AENT
1221.7Smellon#define AENT(x) \
1231.7Smellon	.aent	x, 0
1241.7Smellon#else
1251.7Smellon#define AENT(x)
1261.7Smellon#endif
1271.1Sderaadt#define	ALEAF(x)					\
1281.6Smycroft	.globl	_C_LABEL(x);				\
1291.7Smellon	AENT (_C_LABEL(x))				\
1301.6Smycroft_C_LABEL(x):
1311.1Sderaadt
1321.1Sderaadt/*
1331.1Sderaadt * NON_LEAF(x)
1341.1Sderaadt *
1351.1Sderaadt *	Declare a non-leaf routine (a routine that makes other C calls).
1361.1Sderaadt */
1371.1Sderaadt#define NON_LEAF(x, fsize, retpc) \
1381.6Smycroft	.globl _C_LABEL(x); \
1391.6Smycroft	.ent _C_LABEL(x), 0; \
1401.6Smycroft_C_LABEL(x): ; \
1411.1Sderaadt	.frame sp, fsize, retpc; \
1421.1Sderaadt	MCOUNT
1431.2Sglass
1441.2Sglass/*
1451.2Sglass * NNON_LEAF(x)
1461.2Sglass *
1471.2Sglass *	Declare a non-profiled non-leaf routine
1481.2Sglass *	(a routine that makes other C calls).
1491.2Sglass */
1501.2Sglass#define NNON_LEAF(x, fsize, retpc) \
1511.6Smycroft	.globl _C_LABEL(x); \
1521.6Smycroft	.ent _C_LABEL(x), 0; \
1531.6Smycroft_C_LABEL(x): ; \
1541.2Sglass	.frame sp, fsize, retpc
1551.1Sderaadt
1561.1Sderaadt/*
1571.1Sderaadt * END(x)
1581.1Sderaadt *
1591.1Sderaadt *	Mark end of a procedure.
1601.1Sderaadt */
1611.1Sderaadt#define END(x) \
1621.6Smycroft	.end _C_LABEL(x)
1631.1Sderaadt
1641.1Sderaadt#define STAND_FRAME_SIZE	24
1651.1Sderaadt#define STAND_RA_OFFSET		20
1661.1Sderaadt
1671.1Sderaadt/*
1681.10Schristos * Macros to panic and printf from assembly language.
1691.1Sderaadt */
1701.1Sderaadt#define PANIC(msg) \
1711.1Sderaadt	la	a0, 9f; \
1721.6Smycroft	jal	_C_LABEL(panic); \
1731.1Sderaadt	MSG(msg)
1741.1Sderaadt
1751.1Sderaadt#define	PRINTF(msg) \
1761.1Sderaadt	la	a0, 9f; \
1771.10Schristos	jal	_C_LABEL(printf); \
1781.1Sderaadt	MSG(msg)
1791.1Sderaadt
1801.1Sderaadt#define	MSG(msg) \
1811.1Sderaadt	.rdata; \
1821.1Sderaadt9:	.asciiz	msg; \
1831.1Sderaadt	.text
1841.1Sderaadt
1851.1Sderaadt#define ASMSTR(str) \
1861.1Sderaadt	.asciiz str; \
1871.12Sjonathan	.align	3
1881.1Sderaadt
1891.8Sjonathan#endif /* _MIPS_ASM_H */
190