]>
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 #define ROUND_TO_STACK(len) \
56 (((len) + STACK_INCR - 1) / STACK_INCR * STACK_INCR)
73 * Prologue for functions that may call other functions. Saves
74 * registers and sets up a C frame.
76 #define NESTED_FUNCTION_PROLOGUE(localvarsize) \
77 .set __framesize,ROUND_TO_STACK(localvarsize) ;\
78 .set __nested_function, 1 ;\
83 subl $__framesize, %esp ;\
90 * Prologue for functions that do not call other functions. Does not
91 * save registers (this is the functions responsibility). Does set
94 #define LEAF_FUNCTION_PROLOGUE(localvarsize) \
95 .set __framesize,ROUND_TO_STACK(localvarsize) ;\
96 .set __nested_function, 0 ;\
101 subl $__framesize, %esp ;\
105 * Prologue for any function.
107 * We assume that all Leaf functions will be responsible for saving any
108 * local registers they clobber.
110 #define FUNCTION_EPILOGUE \
111 .if __nested_function ;\
124 * Macros for declaring procedures
126 * Use of these macros allows ctags to have a predictable way
127 * to find various types of declarations. They also simplify
128 * inserting appropriate symbol table information.
130 * NOTE: these simple stubs will be replaced with more
131 * complicated versions once we know what the linker and gdb
132 * will require as far as register use masks and frame declarations.
133 * These macros may also be ifdef'ed in the future to contain profiling
139 * TEXT -- declare start of text segment
145 * DATA -- declare start of data segment
151 * LEAF -- declare global leaf procedure
152 * NOTE: Control SHOULD NOT FLOW into a LEAF! A LEAF should only
153 * be jumped to. (A leaf may do an align.) Use a LABEL() if you
154 * need control to flow into the label.
156 #define LEAF(name, localvarsize) \
160 LEAF_FUNCTION_PROLOGUE(localvarsize)
163 * X_LEAF -- declare alternate global label for leaf
165 #define X_LEAF(name, value) \
170 * P_LEAF -- declare private leaf procedure
172 #define P_LEAF(name, localvarsize) \
175 LEAF_FUNCTION_PROLOGUE(localvarsize)
178 * LABEL -- declare a global code label
179 * MUST be used (rather than LEAF, NESTED, etc) if control
180 * "flows into" the label.
182 #define LABEL(name) \
187 * NESTED -- declare procedure that invokes other procedures
189 #define NESTED(name, localvarsize) \
193 NESTED_FUNCTION_PROLOGUE(localvarsize)
196 * X_NESTED -- declare alternate global label for nested proc
198 #define X_NESTED(name, value) \
203 * P_NESTED -- declare private nested procedure
205 #define P_NESTED(name, localvarsize) \
208 NESTED_FUNCTION_PROLOGUE(localvarsize)
211 * END -- mark end of procedure
218 * Storage definition macros
219 * The main purpose of these is to allow an easy handle for ctags
223 * IMPORT -- import symbol
225 #define IMPORT(name) \
229 * ABS -- declare global absolute symbol
231 #define ABS(name, value) \
236 * P_ABS -- declare private absolute symbol
238 #define P_ABS(name, value) \
242 * EXPORT -- declare global label for data
244 #define EXPORT(name) \
249 * BSS -- declare global zero'ed storage
251 #define BSS(name,size) \
256 * P_BSS -- declare private zero'ed storage
258 #define P_BSS(name,size) \
262 * dynamic/PIC macros for routines which reference external symbols
265 #if defined(__DYNAMIC__)
266 #define PICIFY(var) \
270 movl L ## var ## $non_lazy_ptr-1b(%edx),%edx
272 #define CALL_EXTERN_AGAIN(func) \
276 #define NON_LAZY_STUB(var) \
277 .non_lazy_symbol_pointer ; \
278 L ## var ## $non_lazy_ptr: ; \
279 .indirect_symbol var ; \
283 #define CALL_EXTERN(func) \
284 CALL_EXTERN_AGAIN(func) ; \
287 #define BRANCH_EXTERN(func) \
292 #define PUSH_EXTERN(var) \
298 #define REG_TO_EXTERN(reg, var) \
303 #define EXTERN_TO_REG(var, reg) \
307 movl L ## var ##$non_lazy_ptr-1b(%edx),reg ; \
312 #define BRANCH_EXTERN(func) jmp func
313 #define PUSH_EXTERN(var) pushl var
314 #define CALL_EXTERN(func) call func
315 #define CALL_EXTERN_AGAIN(func) call func
316 #define REG_TO_EXTERN(reg, var) movl reg, var
317 #define EXTERN_TO_REG(var, reg) movl $ ## var, reg
320 #endif /* __ASSEMBLER__ */
322 #endif /* _ARCH_I386_ASM_HELP_H_ */