asm.h revision 1.2 1 /*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Ralph Campbell.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)machAsmDefs.h 8.1 (Berkeley) 6/10/93
37 * $Id: asm.h,v 1.2 1994/05/27 08:40:41 glass Exp $
38 */
39
40 /*
41 * machAsmDefs.h --
42 *
43 * Macros used when writing assembler programs.
44 *
45 * Copyright (C) 1989 Digital Equipment Corporation.
46 * Permission to use, copy, modify, and distribute this software and
47 * its documentation for any purpose and without fee is hereby granted,
48 * provided that the above copyright notice appears in all copies.
49 * Digital Equipment Corporation makes no representations about the
50 * suitability of this software for any purpose. It is provided "as is"
51 * without express or implied warranty.
52 *
53 * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h,
54 * v 1.2 89/08/15 18:28:24 rab Exp SPRITE (DECWRL)
55 * $Id: asm.h,v 1.2 1994/05/27 08:40:41 glass Exp $
56 */
57
58 #ifndef _MACHASMDEFS
59 #define _MACHASMDEFS
60
61 #include <machine/regdef.h>
62
63 /*
64 * Define -pg profile entry code.
65 */
66 #if defined(GPROF) || defined(PROF)
67 #define MCOUNT .set noreorder; \
68 .set noat; \
69 move $1,$31; \
70 jal _mcount; \
71 subu sp,sp,8; \
72 .set reorder; \
73 .set at;
74 #else
75 #define MCOUNT
76 #endif
77
78 /*
79 * LEAF(x)
80 *
81 * Declare a leaf routine.
82 */
83 #define LEAF(x) \
84 .globl x; \
85 .ent x, 0; \
86 x: ; \
87 .frame sp, 0, ra; \
88 MCOUNT
89
90 /*
91 * NLEAF(x)
92 *
93 * Declare a non-profiled leaf routine.
94 */
95 #define NLEAF(x) \
96 .globl x; \
97 .ent x, 0; \
98 x: ; \
99 .frame sp, 0, ra
100
101 /*
102 * ALEAF -- declare alternate entry to a leaf routine.
103 */
104 #define ALEAF(x) \
105 .globl x; \
106 .aent x,0; \
107 x:
108
109 /*
110 * NON_LEAF(x)
111 *
112 * Declare a non-leaf routine (a routine that makes other C calls).
113 */
114 #define NON_LEAF(x, fsize, retpc) \
115 .globl x; \
116 .ent x, 0; \
117 x: ; \
118 .frame sp, fsize, retpc; \
119 MCOUNT
120
121 /*
122 * NNON_LEAF(x)
123 *
124 * Declare a non-profiled non-leaf routine
125 * (a routine that makes other C calls).
126 */
127 #define NNON_LEAF(x, fsize, retpc) \
128 .globl x; \
129 .ent x, 0; \
130 x: ; \
131 .frame sp, fsize, retpc
132
133 /*
134 * END(x)
135 *
136 * Mark end of a procedure.
137 */
138 #define END(x) \
139 .end x
140
141 #define STAND_FRAME_SIZE 24
142 #define STAND_RA_OFFSET 20
143
144 /*
145 * Macros to panic and printf from assembly language.
146 */
147 #define PANIC(msg) \
148 la a0, 9f; \
149 jal panic; \
150 MSG(msg)
151
152 #define PRINTF(msg) \
153 la a0, 9f; \
154 jal printf; \
155 MSG(msg)
156
157 #define MSG(msg) \
158 .rdata; \
159 9: .asciiz msg; \
160 .text
161
162 #define ASMSTR(str) \
163 .asciiz str; \
164 .align 2
165
166 #endif /* _MACHASMDEFS */
167