Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.13.10.1
      1 /*	$NetBSD: asm.h,v 1.13.10.1 1998/10/15 03:25:08 nisimura Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1992, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * Ralph Campbell.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  *	@(#)machAsmDefs.h	8.1 (Berkeley) 6/10/93
     39  */
     40 
     41 /*
     42  * machAsmDefs.h --
     43  *
     44  *	Macros used when writing assembler programs.
     45  *
     46  *	Copyright (C) 1989 Digital Equipment Corporation.
     47  *	Permission to use, copy, modify, and distribute this software and
     48  *	its documentation for any purpose and without fee is hereby granted,
     49  *	provided that the above copyright notice appears in all copies.
     50  *	Digital Equipment Corporation makes no representations about the
     51  *	suitability of this software for any purpose.  It is provided "as is"
     52  *	without express or implied warranty.
     53  *
     54  * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h,
     55  *	v 1.2 89/08/15 18:28:24 rab Exp  SPRITE (DECWRL)
     56  */
     57 
     58 #ifndef _MIPS_ASM_H
     59 #define _MIPS_ASM_H
     60 
     61 /*
     62  * Symbolic register names
     63  */
     64 #define zero	$0	/* always zero */
     65 #define AT	$at	/* assembler temporary */
     66 #define v0	$2	/* return value */
     67 #define v1	$3
     68 #define a0	$4	/* argument registers */
     69 #define a1	$5
     70 #define a2	$6
     71 #define a3	$7
     72 #define t0	$8	/* temp registers (not saved across subroutine calls) */
     73 #define t1	$9
     74 #define t2	$10
     75 #define t3	$11
     76 #define t4	$12
     77 #define t5	$13
     78 #define t6	$14
     79 #define t7	$15
     80 #define s0	$16	/* saved across subroutine calls (callee saved) */
     81 #define s1	$17
     82 #define s2	$18
     83 #define s3	$19
     84 #define s4	$20
     85 #define s5	$21
     86 #define s6	$22
     87 #define s7	$23
     88 #define t8	$24	/* two more temporary registers */
     89 #define t9	$25
     90 #define k0	$26	/* kernel temporary */
     91 #define k1	$27
     92 #define gp	$28	/* global pointer */
     93 #define sp	$29	/* stack pointer */
     94 #define s8	$30	/* one more callee saved */
     95 #define ra	$31	/* return address */
     96 
     97 /*
     98  * Define -pg profile entry code.
     99  * XXX assume .set noreorder for kernel, .set reorder for user code.
    100  */
    101 #define _KERN_MCOUNT		\
    102 	.set	noat;		\
    103 	move	$1,$31;		\
    104 	jal	_mcount;	\
    105 	subu	sp,sp,8;	\
    106 	.set at
    107 
    108 
    109 #ifdef GPROF
    110 # if defined(_KERNEL) || defined(_LOCORE)
    111 #  define MCOUNT _KERN_MCOUNT
    112 # else
    113 #  define MCOUNT .set noreorder; _KERN_MCOUNT ;  .set reorder;
    114 # endif
    115 #else
    116 #define	MCOUNT
    117 #endif
    118 
    119 #ifdef __NO_LEADING_UNDERSCORES__
    120 # define _C_LABEL(x)	x
    121 #else
    122 # ifdef __STDC__
    123 #  define _C_LABEL(x)	_ ## x
    124 # else
    125 #  define _C_LABEL(x)	_/**/x
    126 # endif
    127 #endif
    128 
    129 /*
    130  * LEAF
    131  *	A leaf routine does
    132  *	- call no other function,
    133  *	- never use any register that callee-saved (S0-S8), and
    134  *	- not use any local stack storage.
    135  */
    136 #define LEAF(x)				\
    137 	.globl	_C_LABEL(x);		\
    138 	.ent	_C_LABEL(x), 0;		\
    139 _C_LABEL(x): ;				\
    140 	.frame sp, 0, ra;		\
    141 	MCOUNT
    142 
    143 /*
    144  * LEAF_NOPROFILE
    145  *	No profilable leaf routine.
    146  */
    147 #define LEAF_NOPROFILE(x)		\
    148 	.globl	_C_LABEL(x);		\
    149 	.ent	_C_LABEL(x), 0;		\
    150 _C_LABEL(x): ;				\
    151 	.frame	sp, 0, ra
    152 
    153 /*
    154  * ALIAS
    155  *	Global alias for a function, or alternate entry point
    156  */
    157 #define	ALIAS(x)			\
    158 	.globl	_C_LABEL(x);		\
    159 _C_LABEL(x):
    160 
    161 #ifdef USE_AENT
    162 #define AENT(x)				\
    163 	.aent	x, 0
    164 #else
    165 #define AENT(x)
    166 #endif
    167 
    168 /*
    169  * NESTED(x)
    170  *	A function calls other functions and needs
    171  *	therefore stack space to save/restore registers.
    172  */
    173 #define NESTED(x, fsize, retpc)		\
    174 	.globl	_C_LABEL(x);		\
    175 	.ent	_C_LABEL(x), 0; 	\
    176 _C_LABEL(x): ;				\
    177 	.frame	sp, fsize, retpc;	\
    178 	MCOUNT
    179 
    180 /*
    181  * NESTED_NOPROFILE(x)
    182  *	No profilable nested routine.
    183  */
    184 #define NESTED_NOPROFILE(x, fsize, retpc)	\
    185 	.globl	_C_LABEL(x);		\
    186 	.ent	_C_LABEL(x), 0;		\
    187 _C_LABEL(x): ;				\
    188 	.frame	sp, fsize, retpc
    189 
    190 /*
    191  * END(x)
    192  *	Mark end of a procedure.
    193  */
    194 #define END(x) \
    195 	.end _C_LABEL(x)
    196 
    197 /*
    198  * Macros to panic and printf from assembly language.
    199  */
    200 #define PANIC(msg)			\
    201 	la	a0, 9f;			\
    202 	jal	_C_LABEL(panic);	\
    203 	MSG(msg)
    204 
    205 #define	PRINTF(msg)			\
    206 	la	a0, 9f;			\
    207 	jal	_C_LABEL(printf);	\
    208 	MSG(msg)
    209 
    210 #define	MSG(msg)			\
    211 	.rdata;				\
    212 9:	.asciiz	msg;			\
    213 	.text
    214 
    215 #define ASMSTR(str)			\
    216 	.asciiz str;			\
    217 	.align	3
    218 
    219 #endif /* _MIPS_ASM_H */
    220