asm.h revision 1.4 1 1.4 matt /* $NetBSD: asm.h,v 1.4 2001/07/16 05:43:32 matt Exp $ */
2 1.1 bjh21
3 1.1 bjh21 /*
4 1.1 bjh21 * Copyright (c) 1990 The Regents of the University of California.
5 1.1 bjh21 * All rights reserved.
6 1.1 bjh21 *
7 1.1 bjh21 * This code is derived from software contributed to Berkeley by
8 1.1 bjh21 * William Jolitz.
9 1.1 bjh21 *
10 1.1 bjh21 * Redistribution and use in source and binary forms, with or without
11 1.1 bjh21 * modification, are permitted provided that the following conditions
12 1.1 bjh21 * are met:
13 1.1 bjh21 * 1. Redistributions of source code must retain the above copyright
14 1.1 bjh21 * notice, this list of conditions and the following disclaimer.
15 1.1 bjh21 * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 bjh21 * notice, this list of conditions and the following disclaimer in the
17 1.1 bjh21 * documentation and/or other materials provided with the distribution.
18 1.1 bjh21 * 3. All advertising materials mentioning features or use of this software
19 1.1 bjh21 * must display the following acknowledgement:
20 1.1 bjh21 * This product includes software developed by the University of
21 1.1 bjh21 * California, Berkeley and its contributors.
22 1.1 bjh21 * 4. Neither the name of the University nor the names of its contributors
23 1.1 bjh21 * may be used to endorse or promote products derived from this software
24 1.1 bjh21 * without specific prior written permission.
25 1.1 bjh21 *
26 1.1 bjh21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 1.1 bjh21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 1.1 bjh21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 1.1 bjh21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 1.1 bjh21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 1.1 bjh21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 1.1 bjh21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 1.1 bjh21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 1.1 bjh21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.1 bjh21 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.1 bjh21 * SUCH DAMAGE.
37 1.1 bjh21 *
38 1.1 bjh21 * from: @(#)asm.h 5.5 (Berkeley) 5/7/91
39 1.1 bjh21 */
40 1.1 bjh21
41 1.1 bjh21 #ifndef _ARM32_ASM_H_
42 1.1 bjh21 #define _ARM32_ASM_H_
43 1.1 bjh21
44 1.1 bjh21 #ifdef __ELF__
45 1.1 bjh21 # define _C_LABEL(x) x
46 1.1 bjh21 #else
47 1.1 bjh21 # ifdef __STDC__
48 1.1 bjh21 # define _C_LABEL(x) _ ## x
49 1.1 bjh21 # else
50 1.1 bjh21 # define _C_LABEL(x) _/**/x
51 1.1 bjh21 # endif
52 1.1 bjh21 #endif
53 1.1 bjh21 #define _ASM_LABEL(x) x
54 1.1 bjh21
55 1.1 bjh21 #ifdef __STDC__
56 1.1 bjh21 # define __CONCAT(x,y) x ## y
57 1.1 bjh21 # define __STRING(x) #x
58 1.1 bjh21 #else
59 1.1 bjh21 # define __CONCAT(x,y) x/**/y
60 1.1 bjh21 # define __STRING(x) "x"
61 1.1 bjh21 #endif
62 1.1 bjh21
63 1.1 bjh21 #ifndef _ALIGN_TEXT
64 1.1 bjh21 # define _ALIGN_TEXT .align 0
65 1.1 bjh21 #endif
66 1.1 bjh21
67 1.1 bjh21 /*
68 1.1 bjh21 * gas/arm uses @ as a single comment character and thus cannot be used here
69 1.1 bjh21 * Instead it recognised the # instead of an @ symbols in .type directives
70 1.1 bjh21 * We define a couple of macros so that assembly code will not be dependant
71 1.1 bjh21 * on one or the other.
72 1.1 bjh21 */
73 1.1 bjh21 #define _ASM_TYPE_FUNCTION #function
74 1.1 bjh21 #define _ASM_TYPE_OBJECT #object
75 1.1 bjh21 #define _ENTRY(x) \
76 1.1 bjh21 .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x:
77 1.1 bjh21
78 1.1 bjh21 #ifdef GPROF
79 1.2 bjh21 # ifdef __ELF__
80 1.2 bjh21 # define _PROF_PROLOGUE \
81 1.2 bjh21 mov ip, lr; bl __mcount
82 1.2 bjh21 # else
83 1.2 bjh21 # define _PROF_PROLOGUE \
84 1.1 bjh21 mov ip,lr; bl mcount
85 1.2 bjh21 # endif
86 1.1 bjh21 #else
87 1.1 bjh21 # define _PROF_PROLOGUE
88 1.1 bjh21 #endif
89 1.1 bjh21
90 1.1 bjh21 #define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
91 1.1 bjh21 #define ENTRY_NP(y) _ENTRY(_C_LABEL(y))
92 1.1 bjh21 #define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
93 1.1 bjh21 #define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y))
94 1.1 bjh21
95 1.1 bjh21 #define ASMSTR .asciz
96 1.3 matt
97 1.3 matt #if defined(__ELF__) && defined(PIC)
98 1.4 matt #ifdef __STDC__
99 1.4 matt #define PIC_SYM(x,y) x ## ( ## y ## )
100 1.4 matt #else
101 1.4 matt #define PIC_SYM(x,y) x/**/(/**/y/**/)
102 1.4 matt #endif
103 1.3 matt #else
104 1.4 matt #define PIC_SYM(x,y) x
105 1.3 matt #endif
106 1.1 bjh21
107 1.1 bjh21 #ifdef __ELF__
108 1.1 bjh21 #define RCSID(x) .section ".ident"; .asciz x
109 1.1 bjh21 #else
110 1.1 bjh21 #define RCSID(x) .text; .asciz x
111 1.1 bjh21 #endif
112 1.1 bjh21
113 1.1 bjh21 #ifdef __ELF__
114 1.1 bjh21 #define WEAK_ALIAS(alias,sym) \
115 1.1 bjh21 .weak alias; \
116 1.1 bjh21 alias = sym
117 1.1 bjh21 #endif
118 1.1 bjh21
119 1.1 bjh21 #ifdef __STDC__
120 1.1 bjh21 #define WARN_REFERENCES(sym,msg) \
121 1.1 bjh21 .stabs msg ## ,30,0,0,0 ; \
122 1.1 bjh21 .stabs __STRING(_C_LABEL(sym)) ## ,1,0,0,0
123 1.1 bjh21 #elif defined(__ELF__)
124 1.1 bjh21 #define WARN_REFERENCES(sym,msg) \
125 1.1 bjh21 .stabs msg,30,0,0,0 ; \
126 1.1 bjh21 .stabs __STRING(sym),1,0,0,0
127 1.1 bjh21 #else
128 1.1 bjh21 #define WARN_REFERENCES(sym,msg) \
129 1.1 bjh21 .stabs msg,30,0,0,0 ; \
130 1.1 bjh21 .stabs __STRING(_/**/sym),1,0,0,0
131 1.1 bjh21 #endif /* __STDC__ */
132 1.1 bjh21
133 1.1 bjh21 #endif /* !_ARM_ASM_H_ */
134