]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/architecture/i386/asm_help.h
45f820b8ca922f255ddcaa6c350420e1528ba0b8
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 /* Copyright (c) 1991 NeXT Computer, Inc. All rights reserved.
25 * File: architecture/i386/asm_help.h
26 * Author: Mike DeMoney, NeXT Computer, Inc.
27 * Modified for i386 by: Bruce Martin, NeXT Computer, Inc.
29 * This header file defines macros useful when writing assembly code
30 * for the Intel i386 family processors.
33 * 10-Mar-92 Bruce Martin (bmartin@next.com)
35 * 23-Jan-91 Mike DeMoney (mike@next.com)
39 #ifndef _ARCH_I386_ASM_HELP_H_
40 #define _ARCH_I386_ASM_HELP_H_
42 #include <architecture/i386/reg_help.h>
50 #define ROUND_TO_STACK(len) \
51 (((len) + STACK_INCR - 1) / STACK_INCR * STACK_INCR)
68 * Prologue for functions that may call other functions. Saves
69 * registers and sets up a C frame.
71 #define NESTED_FUNCTION_PROLOGUE(localvarsize) \
72 .set __framesize,ROUND_TO_STACK(localvarsize) ;\
73 .set __nested_function, 1 ;\
78 subl $__framesize, %esp ;\
85 * Prologue for functions that do not call other functions. Does not
86 * save registers (this is the functions responsibility). Does set
89 #define LEAF_FUNCTION_PROLOGUE(localvarsize) \
90 .set __framesize,ROUND_TO_STACK(localvarsize) ;\
91 .set __nested_function, 0 ;\
96 subl $__framesize, %esp ;\
100 * Prologue for any function.
102 * We assume that all Leaf functions will be responsible for saving any
103 * local registers they clobber.
105 #define FUNCTION_EPILOGUE \
106 .if __nested_function ;\
119 * Macros for declaring procedures
121 * Use of these macros allows ctags to have a predictable way
122 * to find various types of declarations. They also simplify
123 * inserting appropriate symbol table information.
125 * NOTE: these simple stubs will be replaced with more
126 * complicated versions once we know what the linker and gdb
127 * will require as far as register use masks and frame declarations.
128 * These macros may also be ifdef'ed in the future to contain profiling
134 * TEXT -- declare start of text segment
140 * DATA -- declare start of data segment
146 * LEAF -- declare global leaf procedure
147 * NOTE: Control SHOULD NOT FLOW into a LEAF! A LEAF should only
148 * be jumped to. (A leaf may do an align.) Use a LABEL() if you
149 * need control to flow into the label.
151 #define LEAF(name, localvarsize) \
155 LEAF_FUNCTION_PROLOGUE(localvarsize)
158 * X_LEAF -- declare alternate global label for leaf
160 #define X_LEAF(name, value) \
165 * P_LEAF -- declare private leaf procedure
167 #define P_LEAF(name, localvarsize) \
170 LEAF_FUNCTION_PROLOGUE(localvarsize)
173 * LABEL -- declare a global code label
174 * MUST be used (rather than LEAF, NESTED, etc) if control
175 * "flows into" the label.
177 #define LABEL(name) \
182 * NESTED -- declare procedure that invokes other procedures
184 #define NESTED(name, localvarsize) \
188 NESTED_FUNCTION_PROLOGUE(localvarsize)
191 * X_NESTED -- declare alternate global label for nested proc
193 #define X_NESTED(name, value) \
198 * P_NESTED -- declare private nested procedure
200 #define P_NESTED(name, localvarsize) \
203 NESTED_FUNCTION_PROLOGUE(localvarsize)
206 * END -- mark end of procedure
213 * Storage definition macros
214 * The main purpose of these is to allow an easy handle for ctags
218 * IMPORT -- import symbol
220 #define IMPORT(name) \
224 * ABS -- declare global absolute symbol
226 #define ABS(name, value) \
231 * P_ABS -- declare private absolute symbol
233 #define P_ABS(name, value) \
237 * EXPORT -- declare global label for data
239 #define EXPORT(name) \
244 * BSS -- declare global zero'ed storage
246 #define BSS(name,size) \
251 * P_BSS -- declare private zero'ed storage
253 #define P_BSS(name,size) \
257 * dynamic/PIC macros for routines which reference external symbols
260 #if defined(__DYNAMIC__)
261 #define PICIFY(var) \
265 movl L ## var ## $non_lazy_ptr-1b(%edx),%edx
267 #define CALL_EXTERN_AGAIN(func) \
271 #define NON_LAZY_STUB(var) \
272 .non_lazy_symbol_pointer ; \
273 L ## var ## $non_lazy_ptr: ; \
274 .indirect_symbol var ; \
278 #define CALL_EXTERN(func) \
279 CALL_EXTERN_AGAIN(func) ; \
282 #define BRANCH_EXTERN(func) \
287 #define PUSH_EXTERN(var) \
293 #define REG_TO_EXTERN(reg, var) \
298 #define EXTERN_TO_REG(var, reg) \
302 movl L ## var ##$non_lazy_ptr-1b(%edx),reg ; \
307 #define BRANCH_EXTERN(func) jmp func
308 #define PUSH_EXTERN(var) pushl var
309 #define CALL_EXTERN(func) call func
310 #define CALL_EXTERN_AGAIN(func) call func
311 #define REG_TO_EXTERN(reg, var) movl reg, var
312 #define EXTERN_TO_REG(var, reg) movl $ ## var, reg
315 #endif /* __ASSEMBLER__ */
317 #endif /* _ARCH_I386_ASM_HELP_H_ */