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