asm.h revision 1.13.10.3 1 1.13.10.3 drochner /* $NetBSD: asm.h,v 1.13.10.3 1998/12/06 21:02:49 drochner 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.11 jtc #ifdef GPROF
109 1.13 jonathan # if defined(_KERNEL) || defined(_LOCORE)
110 1.13 jonathan # define MCOUNT _KERN_MCOUNT
111 1.13 jonathan # else
112 1.13 jonathan # define MCOUNT .set noreorder; _KERN_MCOUNT ; .set reorder;
113 1.13 jonathan # endif
114 1.1 deraadt #else
115 1.1 deraadt #define MCOUNT
116 1.2 glass #endif
117 1.1 deraadt
118 1.7 mellon #ifdef __NO_LEADING_UNDERSCORES__
119 1.6 mycroft # define _C_LABEL(x) x
120 1.6 mycroft #else
121 1.6 mycroft # ifdef __STDC__
122 1.6 mycroft # define _C_LABEL(x) _ ## x
123 1.6 mycroft # else
124 1.6 mycroft # define _C_LABEL(x) _/**/x
125 1.6 mycroft # endif
126 1.6 mycroft #endif
127 1.6 mycroft
128 1.13.10.2 nisimura #ifdef USE_AENT
129 1.13.10.2 nisimura #define AENT(x) \
130 1.13.10.2 nisimura .aent x, 0
131 1.13.10.2 nisimura #else
132 1.13.10.2 nisimura #define AENT(x)
133 1.13.10.2 nisimura #endif
134 1.13.10.3 drochner
135 1.13.10.3 drochner /*
136 1.13.10.3 drochner * WARN_REFERENCES: create a warning if the specified symbol is referenced
137 1.13.10.3 drochner * (ELF only, and thus, no leading underscores).
138 1.13.10.3 drochner */
139 1.13.10.3 drochner #ifdef __ELF__
140 1.13.10.3 drochner #ifdef __STDC__
141 1.13.10.3 drochner #define WARN_REFERENCES(_sym,_msg) \
142 1.13.10.3 drochner .section .gnu.warning. ## _sym ; .ascii _msg ; .text
143 1.13.10.3 drochner #else
144 1.13.10.3 drochner #define WARN_REFERENCES(_sym,_msg) \
145 1.13.10.3 drochner .section .gnu.warning./**/_sym ; .ascii _msg ; .text
146 1.13.10.3 drochner #endif /* __STDC__ */
147 1.13.10.3 drochner #endif /* __ELF__ */
148 1.13.10.2 nisimura
149 1.1 deraadt /*
150 1.13.10.1 nisimura * LEAF
151 1.13.10.1 nisimura * A leaf routine does
152 1.13.10.1 nisimura * - call no other function,
153 1.13.10.1 nisimura * - never use any register that callee-saved (S0-S8), and
154 1.13.10.1 nisimura * - not use any local stack storage.
155 1.13.10.1 nisimura */
156 1.13.10.1 nisimura #define LEAF(x) \
157 1.13.10.1 nisimura .globl _C_LABEL(x); \
158 1.13.10.1 nisimura .ent _C_LABEL(x), 0; \
159 1.13.10.1 nisimura _C_LABEL(x): ; \
160 1.13.10.1 nisimura .frame sp, 0, ra; \
161 1.1 deraadt MCOUNT
162 1.1 deraadt
163 1.1 deraadt /*
164 1.13.10.1 nisimura * LEAF_NOPROFILE
165 1.13.10.1 nisimura * No profilable leaf routine.
166 1.1 deraadt */
167 1.13.10.1 nisimura #define LEAF_NOPROFILE(x) \
168 1.13.10.1 nisimura .globl _C_LABEL(x); \
169 1.13.10.1 nisimura .ent _C_LABEL(x), 0; \
170 1.13.10.1 nisimura _C_LABEL(x): ; \
171 1.13.10.1 nisimura .frame sp, 0, ra
172 1.1 deraadt
173 1.1 deraadt /*
174 1.13.10.2 nisimura * XLEAF
175 1.13.10.2 nisimura * declare alternate entry to leaf routine
176 1.1 deraadt */
177 1.13.10.2 nisimura #define XLEAF(x) \
178 1.13.10.1 nisimura .globl _C_LABEL(x); \
179 1.13.10.2 nisimura .aent _C_LABEL(x),0; \
180 1.13.10.1 nisimura _C_LABEL(x):
181 1.13.10.1 nisimura
182 1.1 deraadt /*
183 1.13.10.2 nisimura * NESTED
184 1.13.10.1 nisimura * A function calls other functions and needs
185 1.13.10.1 nisimura * therefore stack space to save/restore registers.
186 1.13.10.1 nisimura */
187 1.13.10.1 nisimura #define NESTED(x, fsize, retpc) \
188 1.13.10.1 nisimura .globl _C_LABEL(x); \
189 1.13.10.1 nisimura .ent _C_LABEL(x), 0; \
190 1.13.10.1 nisimura _C_LABEL(x): ; \
191 1.13.10.1 nisimura .frame sp, fsize, retpc; \
192 1.1 deraadt MCOUNT
193 1.2 glass
194 1.2 glass /*
195 1.13.10.1 nisimura * NESTED_NOPROFILE(x)
196 1.13.10.1 nisimura * No profilable nested routine.
197 1.2 glass */
198 1.13.10.1 nisimura #define NESTED_NOPROFILE(x, fsize, retpc) \
199 1.13.10.1 nisimura .globl _C_LABEL(x); \
200 1.13.10.1 nisimura .ent _C_LABEL(x), 0; \
201 1.13.10.1 nisimura _C_LABEL(x): ; \
202 1.13.10.1 nisimura .frame sp, fsize, retpc
203 1.1 deraadt
204 1.1 deraadt /*
205 1.13.10.2 nisimura * XNESTED
206 1.13.10.2 nisimura * declare alternate entry point to nested routine.
207 1.13.10.2 nisimura */
208 1.13.10.2 nisimura #define XNESTED(x) \
209 1.13.10.2 nisimura .globl _C_LABEL(x); \
210 1.13.10.2 nisimura .aent _C_LABEL(x),0; \
211 1.13.10.2 nisimura _C_LABEL(x):
212 1.13.10.2 nisimura
213 1.13.10.2 nisimura /*
214 1.13.10.2 nisimura * END
215 1.1 deraadt * Mark end of a procedure.
216 1.1 deraadt */
217 1.1 deraadt #define END(x) \
218 1.6 mycroft .end _C_LABEL(x)
219 1.1 deraadt
220 1.1 deraadt /*
221 1.13.10.2 nisimura * IMPORT -- import external symbol
222 1.13.10.2 nisimura */
223 1.13.10.2 nisimura #define IMPORT(sym, size) \
224 1.13.10.2 nisimura .extern sym,size
225 1.13.10.2 nisimura
226 1.13.10.2 nisimura /*
227 1.13.10.2 nisimura * EXPORT -- export definition of symbol
228 1.13.10.2 nisimura */
229 1.13.10.2 nisimura #define EXPORT(x) \
230 1.13.10.2 nisimura .globl _C_LABEL(x); \
231 1.13.10.2 nisimura _C_LABEL(x):
232 1.13.10.2 nisimura
233 1.13.10.2 nisimura /*
234 1.13.10.2 nisimura * ALIAS
235 1.13.10.2 nisimura * Global alias for a function, or alternate entry point
236 1.13.10.2 nisimura */
237 1.13.10.2 nisimura #define ALIAS(x) \
238 1.13.10.2 nisimura .globl _C_LABEL(x); \
239 1.13.10.2 nisimura _C_LABEL(x):
240 1.13.10.2 nisimura
241 1.13.10.2 nisimura /*
242 1.10 christos * Macros to panic and printf from assembly language.
243 1.1 deraadt */
244 1.13.10.1 nisimura #define PANIC(msg) \
245 1.13.10.1 nisimura la a0, 9f; \
246 1.13.10.1 nisimura jal _C_LABEL(panic); \
247 1.1 deraadt MSG(msg)
248 1.1 deraadt
249 1.13.10.1 nisimura #define PRINTF(msg) \
250 1.13.10.1 nisimura la a0, 9f; \
251 1.13.10.1 nisimura jal _C_LABEL(printf); \
252 1.1 deraadt MSG(msg)
253 1.1 deraadt
254 1.13.10.1 nisimura #define MSG(msg) \
255 1.13.10.1 nisimura .rdata; \
256 1.13.10.1 nisimura 9: .asciiz msg; \
257 1.1 deraadt .text
258 1.1 deraadt
259 1.13.10.1 nisimura #define ASMSTR(str) \
260 1.13.10.1 nisimura .asciiz str; \
261 1.12 jonathan .align 3
262 1.13.10.2 nisimura
263 1.13.10.2 nisimura /*
264 1.13.10.2 nisimura * XXX retain dialects XXX
265 1.13.10.2 nisimura */
266 1.13.10.2 nisimura #define ALEAF(x) \
267 1.13.10.2 nisimura .globl _C_LABEL(x); \
268 1.13.10.2 nisimura AENT (_C_LABEL(x)) \
269 1.13.10.2 nisimura _C_LABEL(x):
270 1.13.10.2 nisimura
271 1.13.10.2 nisimura #define NLEAF(x) \
272 1.13.10.2 nisimura .globl _C_LABEL(x); \
273 1.13.10.2 nisimura .ent _C_LABEL(x), 0; \
274 1.13.10.2 nisimura _C_LABEL(x): ; \
275 1.13.10.2 nisimura .frame sp, 0, ra
276 1.13.10.2 nisimura
277 1.13.10.2 nisimura #define NON_LEAF(x, fsize, retpc) \
278 1.13.10.2 nisimura .globl _C_LABEL(x); \
279 1.13.10.2 nisimura .ent _C_LABEL(x), 0; \
280 1.13.10.2 nisimura _C_LABEL(x): ; \
281 1.13.10.2 nisimura .frame sp, fsize, retpc; \
282 1.13.10.2 nisimura MCOUNT
283 1.13.10.2 nisimura
284 1.13.10.2 nisimura #define NNON_LEAF(x, fsize, retpc) \
285 1.13.10.2 nisimura .globl _C_LABEL(x); \
286 1.13.10.2 nisimura .ent _C_LABEL(x), 0; \
287 1.13.10.2 nisimura _C_LABEL(x): ; \
288 1.13.10.2 nisimura .frame sp, fsize, retpc
289 1.1 deraadt
290 1.8 jonathan #endif /* _MIPS_ASM_H */
291