]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/architecture/i386/asm_help.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* Copyright (c) 1991 NeXT Computer, Inc. All rights reserved.
27 * File: architecture/i386/asm_help.h
28 * Author: Mike DeMoney, NeXT Computer, Inc.
29 * Modified for i386 by: Bruce Martin, NeXT Computer, Inc.
31 * This header file defines macros useful when writing assembly code
32 * for the Intel i386 family processors.
35 * 10-Mar-92 Bruce Martin (bmartin@next.com)
37 * 23-Jan-91 Mike DeMoney (mike@next.com)
41 #ifndef _ARCH_I386_ASM_HELP_H_
42 #define _ARCH_I386_ASM_HELP_H_
44 #include <architecture/i386/reg_help.h>
52 #define ROUND_TO_STACK(len) \
53 (((len) + STACK_INCR - 1) / STACK_INCR * STACK_INCR)
70 * Prologue for functions that may call other functions. Saves
71 * registers and sets up a C frame.
73 #define NESTED_FUNCTION_PROLOGUE(localvarsize) \
74 .set __framesize,ROUND_TO_STACK(localvarsize) ;\
75 .set __nested_function, 1 ;\
80 subl $__framesize, %esp ;\
87 * Prologue for functions that do not call other functions. Does not
88 * save registers (this is the functions responsibility). Does set
91 #define LEAF_FUNCTION_PROLOGUE(localvarsize) \
92 .set __framesize,ROUND_TO_STACK(localvarsize) ;\
93 .set __nested_function, 0 ;\
98 subl $__framesize, %esp ;\
102 * Prologue for any function.
104 * We assume that all Leaf functions will be responsible for saving any
105 * local registers they clobber.
107 #define FUNCTION_EPILOGUE \
108 .if __nested_function ;\
121 * Macros for declaring procedures
123 * Use of these macros allows ctags to have a predictable way
124 * to find various types of declarations. They also simplify
125 * inserting appropriate symbol table information.
127 * NOTE: these simple stubs will be replaced with more
128 * complicated versions once we know what the linker and gdb
129 * will require as far as register use masks and frame declarations.
130 * These macros may also be ifdef'ed in the future to contain profiling
136 * TEXT -- declare start of text segment
142 * DATA -- declare start of data segment
148 * LEAF -- declare global leaf procedure
149 * NOTE: Control SHOULD NOT FLOW into a LEAF! A LEAF should only
150 * be jumped to. (A leaf may do an align.) Use a LABEL() if you
151 * need control to flow into the label.
153 #define LEAF(name, localvarsize) \
157 LEAF_FUNCTION_PROLOGUE(localvarsize)
160 * X_LEAF -- declare alternate global label for leaf
162 #define X_LEAF(name, value) \
167 * P_LEAF -- declare private leaf procedure
169 #define P_LEAF(name, localvarsize) \
172 LEAF_FUNCTION_PROLOGUE(localvarsize)
175 * LABEL -- declare a global code label
176 * MUST be used (rather than LEAF, NESTED, etc) if control
177 * "flows into" the label.
179 #define LABEL(name) \
184 * NESTED -- declare procedure that invokes other procedures
186 #define NESTED(name, localvarsize) \
190 NESTED_FUNCTION_PROLOGUE(localvarsize)
193 * X_NESTED -- declare alternate global label for nested proc
195 #define X_NESTED(name, value) \
200 * P_NESTED -- declare private nested procedure
202 #define P_NESTED(name, localvarsize) \
205 NESTED_FUNCTION_PROLOGUE(localvarsize)
208 * END -- mark end of procedure
215 * Storage definition macros
216 * The main purpose of these is to allow an easy handle for ctags
220 * IMPORT -- import symbol
222 #define IMPORT(name) \
226 * ABS -- declare global absolute symbol
228 #define ABS(name, value) \
233 * P_ABS -- declare private absolute symbol
235 #define P_ABS(name, value) \
239 * EXPORT -- declare global label for data
241 #define EXPORT(name) \
246 * BSS -- declare global zero'ed storage
248 #define BSS(name,size) \
253 * P_BSS -- declare private zero'ed storage
255 #define P_BSS(name,size) \
259 * dynamic/PIC macros for routines which reference external symbols
262 #if defined(__DYNAMIC__)
263 #define PICIFY(var) \
267 movl L ## var ## $non_lazy_ptr-1b(%edx),%edx
269 #define CALL_EXTERN_AGAIN(func) \
273 #define NON_LAZY_STUB(var) \
274 .non_lazy_symbol_pointer ; \
275 L ## var ## $non_lazy_ptr: ; \
276 .indirect_symbol var ; \
280 #define CALL_EXTERN(func) \
281 CALL_EXTERN_AGAIN(func) ; \
284 #define BRANCH_EXTERN(func) \
289 #define PUSH_EXTERN(var) \
295 #define REG_TO_EXTERN(reg, var) \
300 #define EXTERN_TO_REG(var, reg) \
304 movl L ## var ##$non_lazy_ptr-1b(%edx),reg ; \
309 #define BRANCH_EXTERN(func) jmp func
310 #define PUSH_EXTERN(var) pushl var
311 #define CALL_EXTERN(func) call func
312 #define CALL_EXTERN_AGAIN(func) call func
313 #define REG_TO_EXTERN(reg, var) movl reg, var
314 #define EXTERN_TO_REG(var, reg) movl $ ## var, reg
317 #endif /* __ASSEMBLER__ */
319 #endif /* _ARCH_I386_ASM_HELP_H_ */