asm.h revision 1.1.1.2 1 /* $OpenBSD: asm.h,v 1.6 1997/05/11 16:23:42 pefo 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 * Copyright (C) 1989 Digital Equipment Corporation.
39 * Permission to use, copy, modify, and distribute this software and
40 * its documentation for any purpose and without fee is hereby granted,
41 * provided that the above copyright notice appears in all copies.
42 * Digital Equipment Corporation makes no representations about the
43 * suitability of this software for any purpose. It is provided "as is"
44 * without express or implied warranty.
45 */
46
47 #ifndef _MACHASMDEFS
48 #define _MACHASMDEFS
49
50 #include <machine/regdef.h>
51
52 #ifndef ABICALLS
53 #define ABICALLS .abicalls
54 #endif
55
56 #if defined(ABICALLS) && !defined(_KERNEL)
57 ABICALLS
58 #endif
59
60 #define RCSID(x)
61
62 #define _C_LABEL(x) x
63
64 /*
65 * Define how to access unaligned data word
66 */
67 #ifdef MIPSEL
68 #define LWLO lwl
69 #define LWHI lwr
70 #define SWLO swl
71 #define SWHI swr
72 #endif
73 #ifdef MIPSEB
74 #define LWLO lwr
75 #define LWHI lwl
76 #define SWLO swr
77 #define SWHI swl
78 #endif
79
80 /*
81 * Code for setting gp reg if abicalls are used.
82 */
83 #if defined(ABICALLS) && !defined(_KERNEL)
84 #define ABISETUP \
85 .set noreorder; \
86 .cpload t9; \
87 .set reorder;
88 #else
89 #define ABISETUP
90 #endif
91
92 /*
93 * Define -pg profile entry code.
94 */
95 #if defined(GPROF) || defined(PROF)
96 #define MCOUNT \
97 subu sp, sp, 32; \
98 .cprestore 16; \
99 sw ra, 28(sp); \
100 sw gp, 24(sp); \
101 .set noat; \
102 .set noreorder; \
103 move AT, ra; \
104 jal _mcount; \
105 subu sp, sp, 8; \
106 lw ra, 28(sp); \
107 addu sp, sp, 32; \
108 .set reorder; \
109 .set at;
110 #else
111 #define MCOUNT
112 #endif
113
114 /*
115 * LEAF(x)
116 *
117 * Declare a leaf routine.
118 */
119 #define LEAF(x) \
120 .align 3; \
121 .globl x; \
122 .ent x, 0; \
123 x: ; \
124 .frame sp, 0, ra; \
125 ABISETUP \
126 MCOUNT
127
128 #define ALEAF(x) \
129 .globl x; \
130 x:
131
132 /*
133 * NLEAF(x)
134 *
135 * Declare a non-profiled leaf routine.
136 */
137 #define NLEAF(x) \
138 .align 3; \
139 .globl x; \
140 .ent x, 0; \
141 x: ; \
142 .frame sp, 0, ra; \
143 ABISETUP
144
145 /*
146 * NON_LEAF(x)
147 *
148 * Declare a non-leaf routine (a routine that makes other C calls).
149 */
150 #define NON_LEAF(x, fsize, retpc) \
151 .align 3; \
152 .globl x; \
153 .ent x, 0; \
154 x: ; \
155 .frame sp, fsize, retpc; \
156 ABISETUP \
157 MCOUNT
158
159 /*
160 * NNON_LEAF(x)
161 *
162 * Declare a non-profiled non-leaf routine
163 * (a routine that makes other C calls).
164 */
165 #define NNON_LEAF(x, fsize, retpc) \
166 .align 3; \
167 .globl x; \
168 .ent x, 0; \
169 x: ; \
170 .frame sp, fsize, retpc \
171 ABISETUP
172
173 /*
174 * END(x)
175 *
176 * Mark end of a procedure.
177 */
178 #define END(x) \
179 .end x
180
181 #define STAND_FRAME_SIZE 24
182 #define STAND_RA_OFFSET 20
183
184 /*
185 * Macros to panic and printf from assembly language.
186 */
187 #define PANIC(msg) \
188 la a0, 9f; \
189 jal panic; \
190 MSG(msg)
191
192 #define PRINTF(msg) \
193 la a0, 9f; \
194 jal printf; \
195 MSG(msg)
196
197 #define MSG(msg) \
198 .rdata; \
199 9: .asciiz msg; \
200 .text
201
202 #define ASMSTR(str) \
203 .asciiz str; \
204 .align 3
205
206 #endif /* _MACHASMDEFS */
207