Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.1.1.2
      1  1.1.1.2      soda /*      $OpenBSD: asm.h,v 1.6 1997/05/11 16:23:42 pefo Exp $	*/
      2  1.1.1.2      soda 
      3      1.1  jonathan /*
      4      1.1  jonathan  * Copyright (c) 1992, 1993
      5      1.1  jonathan  *	The Regents of the University of California.  All rights reserved.
      6      1.1  jonathan  *
      7      1.1  jonathan  * This code is derived from software contributed to Berkeley by
      8      1.1  jonathan  * Ralph Campbell.
      9      1.1  jonathan  *
     10      1.1  jonathan  * Redistribution and use in source and binary forms, with or without
     11      1.1  jonathan  * modification, are permitted provided that the following conditions
     12      1.1  jonathan  * are met:
     13      1.1  jonathan  * 1. Redistributions of source code must retain the above copyright
     14      1.1  jonathan  *    notice, this list of conditions and the following disclaimer.
     15      1.1  jonathan  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.1  jonathan  *    notice, this list of conditions and the following disclaimer in the
     17      1.1  jonathan  *    documentation and/or other materials provided with the distribution.
     18      1.1  jonathan  * 3. All advertising materials mentioning features or use of this software
     19      1.1  jonathan  *    must display the following acknowledgement:
     20      1.1  jonathan  *	This product includes software developed by the University of
     21      1.1  jonathan  *	California, Berkeley and its contributors.
     22      1.1  jonathan  * 4. Neither the name of the University nor the names of its contributors
     23      1.1  jonathan  *    may be used to endorse or promote products derived from this software
     24      1.1  jonathan  *    without specific prior written permission.
     25      1.1  jonathan  *
     26      1.1  jonathan  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27      1.1  jonathan  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28      1.1  jonathan  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29      1.1  jonathan  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30      1.1  jonathan  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31      1.1  jonathan  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32      1.1  jonathan  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33      1.1  jonathan  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34      1.1  jonathan  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35      1.1  jonathan  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36      1.1  jonathan  * SUCH DAMAGE.
     37      1.1  jonathan  *
     38      1.1  jonathan  *	Copyright (C) 1989 Digital Equipment Corporation.
     39      1.1  jonathan  *	Permission to use, copy, modify, and distribute this software and
     40      1.1  jonathan  *	its documentation for any purpose and without fee is hereby granted,
     41      1.1  jonathan  *	provided that the above copyright notice appears in all copies.
     42      1.1  jonathan  *	Digital Equipment Corporation makes no representations about the
     43      1.1  jonathan  *	suitability of this software for any purpose.  It is provided "as is"
     44      1.1  jonathan  *	without express or implied warranty.
     45      1.1  jonathan  */
     46      1.1  jonathan 
     47      1.1  jonathan #ifndef _MACHASMDEFS
     48      1.1  jonathan #define _MACHASMDEFS
     49      1.1  jonathan 
     50      1.1  jonathan #include <machine/regdef.h>
     51      1.1  jonathan 
     52  1.1.1.2      soda #ifndef ABICALLS
     53  1.1.1.2      soda #define	ABICALLS	.abicalls
     54  1.1.1.2      soda #endif
     55  1.1.1.2      soda 
     56  1.1.1.2      soda #if defined(ABICALLS) && !defined(_KERNEL)
     57  1.1.1.2      soda 	ABICALLS
     58  1.1.1.2      soda #endif
     59  1.1.1.2      soda 
     60  1.1.1.2      soda #define RCSID(x)
     61  1.1.1.2      soda 
     62      1.1  jonathan #define _C_LABEL(x) x
     63      1.1  jonathan 
     64      1.1  jonathan /*
     65  1.1.1.2      soda  * Define how to access unaligned data word
     66  1.1.1.2      soda  */
     67  1.1.1.2      soda #ifdef MIPSEL
     68  1.1.1.2      soda #define LWLO    lwl
     69  1.1.1.2      soda #define LWHI    lwr
     70  1.1.1.2      soda #define	SWLO	swl
     71  1.1.1.2      soda #define	SWHI	swr
     72  1.1.1.2      soda #endif
     73  1.1.1.2      soda #ifdef MIPSEB
     74  1.1.1.2      soda #define LWLO    lwr
     75  1.1.1.2      soda #define LWHI    lwl
     76  1.1.1.2      soda #define	SWLO	swr
     77  1.1.1.2      soda #define	SWHI	swl
     78  1.1.1.2      soda #endif
     79  1.1.1.2      soda 
     80  1.1.1.2      soda /*
     81  1.1.1.2      soda  * Code for setting gp reg if abicalls are used.
     82  1.1.1.2      soda  */
     83  1.1.1.2      soda #if defined(ABICALLS) && !defined(_KERNEL)
     84  1.1.1.2      soda #define	ABISETUP		\
     85  1.1.1.2      soda 	.set	noreorder;	\
     86  1.1.1.2      soda 	.cpload	t9;		\
     87  1.1.1.2      soda 	.set	reorder;
     88  1.1.1.2      soda #else
     89  1.1.1.2      soda #define	ABISETUP
     90  1.1.1.2      soda #endif
     91  1.1.1.2      soda 
     92  1.1.1.2      soda /*
     93      1.1  jonathan  * Define -pg profile entry code.
     94      1.1  jonathan  */
     95      1.1  jonathan #if defined(GPROF) || defined(PROF)
     96  1.1.1.2      soda #define	MCOUNT			\
     97  1.1.1.2      soda 	subu 	sp, sp, 32;	\
     98  1.1.1.2      soda 	.cprestore 16;		\
     99  1.1.1.2      soda 	sw	ra, 28(sp);	\
    100  1.1.1.2      soda 	sw	gp, 24(sp);	\
    101  1.1.1.2      soda 	.set	noat;		\
    102  1.1.1.2      soda 	.set	noreorder;	\
    103  1.1.1.2      soda 	move	AT, ra;		\
    104  1.1.1.2      soda 	jal	_mcount;	\
    105  1.1.1.2      soda 	subu	sp, sp, 8;	\
    106  1.1.1.2      soda 	lw	ra, 28(sp);	\
    107  1.1.1.2      soda 	addu	sp, sp, 32;	\
    108  1.1.1.2      soda 	.set reorder;		\
    109  1.1.1.2      soda 	.set	at;
    110      1.1  jonathan #else
    111      1.1  jonathan #define	MCOUNT
    112      1.1  jonathan #endif
    113      1.1  jonathan 
    114      1.1  jonathan /*
    115      1.1  jonathan  * LEAF(x)
    116      1.1  jonathan  *
    117      1.1  jonathan  *	Declare a leaf routine.
    118      1.1  jonathan  */
    119  1.1.1.2      soda #define LEAF(x)			\
    120  1.1.1.2      soda 	.align	3;		\
    121  1.1.1.2      soda 	.globl x;		\
    122  1.1.1.2      soda 	.ent x, 0;		\
    123  1.1.1.2      soda x: ;				\
    124  1.1.1.2      soda 	.frame sp, 0, ra;	\
    125  1.1.1.2      soda 	ABISETUP		\
    126      1.1  jonathan 	MCOUNT
    127      1.1  jonathan 
    128  1.1.1.2      soda #define	ALEAF(x)		\
    129  1.1.1.2      soda 	.globl	x;		\
    130  1.1.1.2      soda x:
    131  1.1.1.2      soda 
    132      1.1  jonathan /*
    133      1.1  jonathan  * NLEAF(x)
    134      1.1  jonathan  *
    135      1.1  jonathan  *	Declare a non-profiled leaf routine.
    136      1.1  jonathan  */
    137  1.1.1.2      soda #define NLEAF(x)		\
    138  1.1.1.2      soda 	.align	3;		\
    139  1.1.1.2      soda 	.globl x;		\
    140  1.1.1.2      soda 	.ent x, 0;		\
    141  1.1.1.2      soda x: ;				\
    142  1.1.1.2      soda 	.frame sp, 0, ra;	\
    143  1.1.1.2      soda 	ABISETUP
    144      1.1  jonathan 
    145      1.1  jonathan /*
    146      1.1  jonathan  * NON_LEAF(x)
    147      1.1  jonathan  *
    148      1.1  jonathan  *	Declare a non-leaf routine (a routine that makes other C calls).
    149      1.1  jonathan  */
    150      1.1  jonathan #define NON_LEAF(x, fsize, retpc) \
    151  1.1.1.2      soda 	.align	3;		\
    152  1.1.1.2      soda 	.globl x;		\
    153  1.1.1.2      soda 	.ent x, 0;		\
    154  1.1.1.2      soda x: ;				\
    155      1.1  jonathan 	.frame sp, fsize, retpc; \
    156  1.1.1.2      soda 	ABISETUP		\
    157      1.1  jonathan 	MCOUNT
    158      1.1  jonathan 
    159      1.1  jonathan /*
    160      1.1  jonathan  * NNON_LEAF(x)
    161      1.1  jonathan  *
    162      1.1  jonathan  *	Declare a non-profiled non-leaf routine
    163      1.1  jonathan  *	(a routine that makes other C calls).
    164      1.1  jonathan  */
    165      1.1  jonathan #define NNON_LEAF(x, fsize, retpc) \
    166  1.1.1.2      soda 	.align	3;		\
    167  1.1.1.2      soda 	.globl x;		\
    168  1.1.1.2      soda 	.ent x, 0;		\
    169  1.1.1.2      soda x: ;				\
    170  1.1.1.2      soda 	.frame sp, fsize, retpc	\
    171  1.1.1.2      soda 	ABISETUP
    172      1.1  jonathan 
    173      1.1  jonathan /*
    174      1.1  jonathan  * END(x)
    175      1.1  jonathan  *
    176      1.1  jonathan  *	Mark end of a procedure.
    177      1.1  jonathan  */
    178      1.1  jonathan #define END(x) \
    179      1.1  jonathan 	.end x
    180      1.1  jonathan 
    181      1.1  jonathan #define STAND_FRAME_SIZE	24
    182      1.1  jonathan #define STAND_RA_OFFSET		20
    183      1.1  jonathan 
    184      1.1  jonathan /*
    185      1.1  jonathan  * Macros to panic and printf from assembly language.
    186      1.1  jonathan  */
    187      1.1  jonathan #define PANIC(msg) \
    188      1.1  jonathan 	la	a0, 9f; \
    189      1.1  jonathan 	jal	panic; \
    190      1.1  jonathan 	MSG(msg)
    191      1.1  jonathan 
    192      1.1  jonathan #define	PRINTF(msg) \
    193      1.1  jonathan 	la	a0, 9f; \
    194      1.1  jonathan 	jal	printf; \
    195      1.1  jonathan 	MSG(msg)
    196      1.1  jonathan 
    197      1.1  jonathan #define	MSG(msg) \
    198      1.1  jonathan 	.rdata; \
    199      1.1  jonathan 9:	.asciiz	msg; \
    200      1.1  jonathan 	.text
    201      1.1  jonathan 
    202      1.1  jonathan #define ASMSTR(str) \
    203      1.1  jonathan 	.asciiz str; \
    204      1.1  jonathan 	.align	3
    205      1.1  jonathan 
    206      1.1  jonathan #endif /* _MACHASMDEFS */
    207