xref: /freebsd/sys/i386/include/asm.h (revision 644ba7e84e4faaa9aa80319ccaad458461c3b99b)
1644ba7e8SBruce Evans /*-
2644ba7e8SBruce Evans  * Copyright (c) 1990 The Regents of the University of California.
3644ba7e8SBruce Evans  * All rights reserved.
4644ba7e8SBruce Evans  *
5644ba7e8SBruce Evans  * This code is derived from software contributed to Berkeley by
6644ba7e8SBruce Evans  * William Jolitz.
7644ba7e8SBruce Evans  *
8644ba7e8SBruce Evans  * Redistribution and use in source and binary forms, with or without
9644ba7e8SBruce Evans  * modification, are permitted provided that the following conditions
10644ba7e8SBruce Evans  * are met:
11644ba7e8SBruce Evans  * 1. Redistributions of source code must retain the above copyright
12644ba7e8SBruce Evans  *    notice, this list of conditions and the following disclaimer.
13644ba7e8SBruce Evans  * 2. Redistributions in binary form must reproduce the above copyright
14644ba7e8SBruce Evans  *    notice, this list of conditions and the following disclaimer in the
15644ba7e8SBruce Evans  *    documentation and/or other materials provided with the distribution.
16644ba7e8SBruce Evans  * 3. All advertising materials mentioning features or use of this software
17644ba7e8SBruce Evans  *    must display the following acknowledgement:
18644ba7e8SBruce Evans  *	This product includes software developed by the University of
19644ba7e8SBruce Evans  *	California, Berkeley and its contributors.
20644ba7e8SBruce Evans  * 4. Neither the name of the University nor the names of its contributors
21644ba7e8SBruce Evans  *    may be used to endorse or promote products derived from this software
22644ba7e8SBruce Evans  *    without specific prior written permission.
23644ba7e8SBruce Evans  *
24644ba7e8SBruce Evans  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25644ba7e8SBruce Evans  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26644ba7e8SBruce Evans  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27644ba7e8SBruce Evans  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28644ba7e8SBruce Evans  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29644ba7e8SBruce Evans  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30644ba7e8SBruce Evans  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31644ba7e8SBruce Evans  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32644ba7e8SBruce Evans  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33644ba7e8SBruce Evans  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34644ba7e8SBruce Evans  * SUCH DAMAGE.
35644ba7e8SBruce Evans  *
36644ba7e8SBruce Evans  *	from: @(#)DEFS.h	5.1 (Berkeley) 4/23/90
37644ba7e8SBruce Evans  *	$Id$
38644ba7e8SBruce Evans  */
39644ba7e8SBruce Evans 
40644ba7e8SBruce Evans #include <sys/cdefs.h>
41644ba7e8SBruce Evans 
42644ba7e8SBruce Evans #ifdef PIC
43644ba7e8SBruce Evans #define	PIC_PROLOGUE	\
44644ba7e8SBruce Evans 	pushl	%ebx;	\
45644ba7e8SBruce Evans 	call	1f;	\
46644ba7e8SBruce Evans 1:			\
47644ba7e8SBruce Evans 	popl	%ebx;	\
48644ba7e8SBruce Evans 	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx
49644ba7e8SBruce Evans #define	PIC_EPILOGUE	\
50644ba7e8SBruce Evans 	popl	%ebx
51644ba7e8SBruce Evans #define	PIC_PLT(x)	x@PLT
52644ba7e8SBruce Evans #define	PIC_GOT(x)	x@GOT(%ebx)
53644ba7e8SBruce Evans #define	PIC_GOTOFF(x)	x@GOTOFF(%ebx)
54644ba7e8SBruce Evans #else
55644ba7e8SBruce Evans #define	PIC_PROLOGUE
56644ba7e8SBruce Evans #define	PIC_EPILOGUE
57644ba7e8SBruce Evans #define	PIC_PLT(x)	x
58644ba7e8SBruce Evans #define	PIC_GOT(x)	x
59644ba7e8SBruce Evans #define	PIC_GOTOFF(x)	x
60644ba7e8SBruce Evans #endif
61644ba7e8SBruce Evans 
62644ba7e8SBruce Evans /*
63644ba7e8SBruce Evans  * CNAME and HIDENAME manage the relationship between symbol names in C
64644ba7e8SBruce Evans  * and the equivalent assembly language names.  CNAME is given a name as
65644ba7e8SBruce Evans  * it would be used in a C program.  It expands to the equivalent assembly
66644ba7e8SBruce Evans  * language name.  HIDENAME is given an assembly-language name, and expands
67644ba7e8SBruce Evans  * to a possibly-modified form that will be invisible to C programs.
68644ba7e8SBruce Evans  */
69644ba7e8SBruce Evans #if defined(__ELF__) /* { */
70644ba7e8SBruce Evans #define CNAME(csym)		csym
71644ba7e8SBruce Evans #define HIDENAME(asmsym)	__CONCAT(.,asmsym)
72644ba7e8SBruce Evans #else /* } { */
73644ba7e8SBruce Evans #define CNAME(csym)		__CONCAT(_,csym)
74644ba7e8SBruce Evans #define HIDENAME(asmsym)	asmsym
75644ba7e8SBruce Evans #endif /* } */
76644ba7e8SBruce Evans 
77644ba7e8SBruce Evans 
78644ba7e8SBruce Evans /* XXX should use align 4,0x90 for -m486. */
79644ba7e8SBruce Evans #define _START_ENTRY	.text; .align 2,0x90;
80644ba7e8SBruce Evans #if 0
81644ba7e8SBruce Evans /* Data is not used, except perhaps by non-g prof, which we don't support. */
82644ba7e8SBruce Evans #define _MID_ENTRY	.data; .align 2; 8:; .long 0;		\
83644ba7e8SBruce Evans 			.text; lea 8b,%eax;
84644ba7e8SBruce Evans #else
85644ba7e8SBruce Evans #define _MID_ENTRY
86644ba7e8SBruce Evans #endif
87644ba7e8SBruce Evans 
88644ba7e8SBruce Evans #ifdef PROF
89644ba7e8SBruce Evans 
90644ba7e8SBruce Evans #define ALTENTRY(x)	_START_ENTRY	\
91644ba7e8SBruce Evans 			.globl CNAME(x); .type CNAME(x),@function; CNAME(x):; \
92644ba7e8SBruce Evans 			_MID_ENTRY	\
93644ba7e8SBruce Evans 			call HIDENAME(mcount); jmp 9f
94644ba7e8SBruce Evans 
95644ba7e8SBruce Evans #define ENTRY(x)	_START_ENTRY	\
96644ba7e8SBruce Evans 			.globl CNAME(x); .type CNAME(x),@function; CNAME(x):; \
97644ba7e8SBruce Evans 			_MID_ENTRY	\
98644ba7e8SBruce Evans 			call HIDENAME(mcount); 9:
99644ba7e8SBruce Evans 
100644ba7e8SBruce Evans 
101644ba7e8SBruce Evans #define	ALTASENTRY(x)	_START_ENTRY	\
102644ba7e8SBruce Evans 			.globl x; .type x,@function; x:;	\
103644ba7e8SBruce Evans 			_MID_ENTRY	\
104644ba7e8SBruce Evans 			call HIDENAME(mcount); jmp 9f
105644ba7e8SBruce Evans 
106644ba7e8SBruce Evans #define	ASENTRY(x)	_START_ENTRY	\
107644ba7e8SBruce Evans 			.globl x; .type x,@function; x:;	\
108644ba7e8SBruce Evans 			_MID_ENTRY	\
109644ba7e8SBruce Evans 			call HIDENAME(mcount); 9:
110644ba7e8SBruce Evans 
111644ba7e8SBruce Evans #else	/* !PROF */
112644ba7e8SBruce Evans 
113644ba7e8SBruce Evans #define	ENTRY(x)	_START_ENTRY .globl CNAME(x); .type CNAME(x),@function; \
114644ba7e8SBruce Evans 			CNAME(x):
115644ba7e8SBruce Evans #define	ALTENTRY(x)	ENTRY(x)
116644ba7e8SBruce Evans 
117644ba7e8SBruce Evans #define	ASENTRY(x)	_START_ENTRY .globl x; .type x,@function; x:
118644ba7e8SBruce Evans #define	ALTASENTRY(x)	ASENTRY(x)
119644ba7e8SBruce Evans 
120644ba7e8SBruce Evans #endif
121