]>
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_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright (c) 1991 NeXT Computer, Inc. All rights reserved.
30 * File: architecture/i386/asm_help.h
31 * Author: Mike DeMoney, NeXT Computer, Inc.
32 * Modified for i386 by: Bruce Martin, NeXT Computer, Inc.
34 * This header file defines macros useful when writing assembly code
35 * for the Intel i386 family processors.
38 * 10-Mar-92 Bruce Martin (bmartin@next.com)
40 * 23-Jan-91 Mike DeMoney (mike@next.com)
44 #ifndef _ARCH_I386_ASM_HELP_H_
45 #define _ARCH_I386_ASM_HELP_H_
47 #include <architecture/i386/reg_help.h>
55 /* Note that ROUND_TO_STACK rounds to Intel's stack alignment requirement,
56 * but it is not sufficient for the Apple ABI which requires a 16-byte
57 * aligned stack. Various parts of the OS depend on this requirement,
60 #define ROUND_TO_STACK(len) \
61 (((len) + STACK_INCR - 1) / STACK_INCR * STACK_INCR)
78 * Prologue for functions that may call other functions. Saves
79 * registers and sets up a C frame.
81 #define NESTED_FUNCTION_PROLOGUE(localvarsize) \
82 .set __framesize,ROUND_TO_STACK(localvarsize) ;\
83 .set __nested_function, 1 ;\
88 subl $__framesize, %esp ;\
95 * Prologue for functions that do not call other functions. Does not
96 * save registers (this is the functions responsibility). Does set
99 #define LEAF_FUNCTION_PROLOGUE(localvarsize) \
100 .set __framesize,ROUND_TO_STACK(localvarsize) ;\
101 .set __nested_function, 0 ;\
106 subl $__framesize, %esp ;\
110 * Prologue for any function.
112 * We assume that all Leaf functions will be responsible for saving any
113 * local registers they clobber.
115 #define FUNCTION_EPILOGUE \
116 .if __nested_function ;\
129 * Macros for declaring procedures
131 * Use of these macros allows ctags to have a predictable way
132 * to find various types of declarations. They also simplify
133 * inserting appropriate symbol table information.
135 * NOTE: these simple stubs will be replaced with more
136 * complicated versions once we know what the linker and gdb
137 * will require as far as register use masks and frame declarations.
138 * These macros may also be ifdef'ed in the future to contain profiling
144 * TEXT -- declare start of text segment
150 * DATA -- declare start of data segment
156 * LEAF -- declare global leaf procedure
157 * NOTE: Control SHOULD NOT FLOW into a LEAF! A LEAF should only
158 * be jumped to. (A leaf may do an align.) Use a LABEL() if you
159 * need control to flow into the label.
161 #define LEAF(name, localvarsize) \
165 LEAF_FUNCTION_PROLOGUE(localvarsize)
168 * X_LEAF -- declare alternate global label for leaf
170 #define X_LEAF(name, value) \
175 * P_LEAF -- declare private leaf procedure
177 #define P_LEAF(name, localvarsize) \
180 LEAF_FUNCTION_PROLOGUE(localvarsize)
183 * LABEL -- declare a global code label
184 * MUST be used (rather than LEAF, NESTED, etc) if control
185 * "flows into" the label.
187 #define LABEL(name) \
192 * NESTED -- declare procedure that invokes other procedures
194 #define NESTED(name, localvarsize) \
198 NESTED_FUNCTION_PROLOGUE(localvarsize)
201 * X_NESTED -- declare alternate global label for nested proc
203 #define X_NESTED(name, value) \
208 * P_NESTED -- declare private nested procedure
210 #define P_NESTED(name, localvarsize) \
213 NESTED_FUNCTION_PROLOGUE(localvarsize)
216 * END -- mark end of procedure
223 * Storage definition macros
224 * The main purpose of these is to allow an easy handle for ctags
228 * IMPORT -- import symbol
230 #define IMPORT(name) \
234 * ABS -- declare global absolute symbol
236 #define ABS(name, value) \
241 * P_ABS -- declare private absolute symbol
243 #define P_ABS(name, value) \
247 * EXPORT -- declare global label for data
249 #define EXPORT(name) \
254 * BSS -- declare global zero'ed storage
256 #define BSS(name,size) \
261 * P_BSS -- declare private zero'ed storage
263 #define P_BSS(name,size) \
267 * dynamic/PIC macros for routines which reference external symbols
270 #if defined(__DYNAMIC__)
271 #define PICIFY(var) \
275 movl L ## var ## $non_lazy_ptr-1b(%edx),%edx
277 #define CALL_EXTERN_AGAIN(func) \
281 #define NON_LAZY_STUB(var) \
282 .non_lazy_symbol_pointer ; \
283 L ## var ## $non_lazy_ptr: ; \
284 .indirect_symbol var ; \
288 #define CALL_EXTERN(func) \
289 CALL_EXTERN_AGAIN(func) ; \
292 #define BRANCH_EXTERN(func) \
297 #define PUSH_EXTERN(var) \
303 #define REG_TO_EXTERN(reg, var) \
308 #define EXTERN_TO_REG(var, reg) \
312 movl L ## var ##$non_lazy_ptr-1b(%edx),reg ; \
317 #define BRANCH_EXTERN(func) jmp func
318 #define PUSH_EXTERN(var) pushl var
319 #define CALL_EXTERN(func) call func
320 #define CALL_EXTERN_AGAIN(func) call func
321 #define REG_TO_EXTERN(reg, var) movl reg, var
322 #define EXTERN_TO_REG(var, reg) movl $ ## var, reg
325 #endif /* __ASSEMBLER__ */
327 #endif /* _ARCH_I386_ASM_HELP_H_ */