]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /* $NetBSD: asm.h,v 1.4 2006/08/30 11:14:23 cherry Exp $ */\r |
2 | \r | |
3 | /* -\r | |
4 | * Copyright (c) 1991,1990,1989,1994,1995,1996 Carnegie Mellon University\r | |
5 | * All Rights Reserved.\r | |
6 | * \r | |
7 | * Permission to use, copy, modify and distribute this software and its\r | |
8 | * documentation is hereby granted, provided that both the copyright\r | |
9 | * notice and this permission notice appear in all copies of the\r | |
10 | * software, derivative works or modified versions, and any portions\r | |
11 | * thereof, and that both notices appear in supporting documentation.\r | |
12 | * \r | |
13 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"\r | |
14 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR\r | |
15 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.\r | |
16 | * \r | |
17 | * Carnegie Mellon requests users of this software to return to\r | |
18 | * \r | |
19 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU\r | |
20 | * School of Computer Science\r | |
21 | * Carnegie Mellon University\r | |
22 | * Pittsburgh PA 15213-3890\r | |
23 | * \r | |
24 | * any improvements or extensions that they make and grant Carnegie Mellon\r | |
25 | * the rights to redistribute these changes.\r | |
26 | */\r | |
27 | \r | |
28 | /*\r | |
29 | * Assembly coding style\r | |
30 | *\r | |
31 | * This file contains macros and register defines to\r | |
32 | * aid in writing more readable assembly code.\r | |
33 | * Some rules to make assembly code understandable by\r | |
34 | * a debugger are also noted.\r | |
35 | */\r | |
36 | \r | |
37 | /*\r | |
38 | * Macro to make a local label name.\r | |
39 | */\r | |
40 | #define LLABEL(name,num) L ## name ## num\r | |
41 | \r | |
42 | /*\r | |
43 | * MCOUNT\r | |
44 | */\r | |
45 | #if defined(GPROF)\r | |
46 | #define MCOUNT \\r | |
47 | alloc out0 = ar.pfs, 8, 0, 4, 0; \\r | |
48 | mov out1 = r1; \\r | |
49 | mov out2 = b0;; \\r | |
50 | mov out3 = r0; \\r | |
51 | br.call.sptk b0 = _mcount;;\r | |
52 | #else\r | |
53 | #define MCOUNT /* nothing */\r | |
54 | #endif\r | |
55 | \r | |
56 | /*\r | |
57 | * ENTRY\r | |
58 | * Declare a global leaf function.\r | |
59 | * A leaf function does not call other functions.\r | |
60 | */\r | |
61 | #define ENTRY(_name_, _n_args_) \\r | |
62 | .global _name_; \\r | |
63 | .align 16; \\r | |
64 | .proc _name_; \\r | |
65 | _name_:; \\r | |
66 | .regstk _n_args_, 0, 0, 0; \\r | |
67 | MCOUNT\r | |
68 | \r | |
69 | #define ENTRY_NOPROFILE(_name_, _n_args_) \\r | |
70 | .global _name_; \\r | |
71 | .align 16; \\r | |
72 | .proc _name_; \\r | |
73 | _name_:; \\r | |
74 | .regstk _n_args_, 0, 0, 0\r | |
75 | \r | |
76 | /*\r | |
77 | * STATIC_ENTRY\r | |
78 | * Declare a local leaf function.\r | |
79 | */\r | |
80 | #define STATIC_ENTRY(_name_, _n_args_) \\r | |
81 | .align 16; \\r | |
82 | .proc _name_; \\r | |
83 | _name_:; \\r | |
84 | .regstk _n_args_, 0, 0, 0 \\r | |
85 | MCOUNT\r | |
86 | /*\r | |
87 | * XENTRY\r | |
88 | * Global alias for a leaf function, or alternate entry point\r | |
89 | */\r | |
90 | #define XENTRY(_name_) \\r | |
91 | .globl _name_; \\r | |
92 | _name_:\r | |
93 | \r | |
94 | /*\r | |
95 | * STATIC_XENTRY\r | |
96 | * Local alias for a leaf function, or alternate entry point\r | |
97 | */\r | |
98 | #define STATIC_XENTRY(_name_) \\r | |
99 | _name_:\r | |
100 | \r | |
101 | \r | |
102 | /*\r | |
103 | * END\r | |
104 | * Function delimiter\r | |
105 | */\r | |
106 | #define END(_name_) \\r | |
107 | .endp _name_\r | |
108 | \r | |
109 | \r | |
110 | /*\r | |
111 | * EXPORT\r | |
112 | * Export a symbol\r | |
113 | */\r | |
114 | #define EXPORT(_name_) \\r | |
115 | .global _name_; \\r | |
116 | _name_:\r | |
117 | \r | |
118 | \r | |
119 | /*\r | |
120 | * IMPORT\r | |
121 | * Make an external name visible, typecheck the size\r | |
122 | */\r | |
123 | #define IMPORT(_name_, _size_) \\r | |
124 | /* .extern _name_,_size_ */\r | |
125 | \r | |
126 | \r | |
127 | /*\r | |
128 | * ABS\r | |
129 | * Define an absolute symbol\r | |
130 | */\r | |
131 | #define ABS(_name_, _value_) \\r | |
132 | .globl _name_; \\r | |
133 | _name_ = _value_\r | |
134 | \r | |
135 | \r | |
136 | /*\r | |
137 | * BSS\r | |
138 | * Allocate un-initialized space for a global symbol\r | |
139 | */\r | |
140 | #define BSS(_name_,_numbytes_) \\r | |
141 | .comm _name_,_numbytes_\r | |
142 | \r | |
143 | \r | |
144 | /*\r | |
145 | * MSG\r | |
146 | * Allocate space for a message (a read-only ascii string)\r | |
147 | */\r | |
148 | #define ASCIZ .asciz\r | |
149 | #define MSG(msg,reg,label) \\r | |
150 | addl reg,@ltoff(label),gp;; \\r | |
151 | ld8 reg=[reg];; \\r | |
152 | .data; \\r | |
153 | label: ASCIZ msg; \\r | |
154 | .text;\r | |
155 | \r | |
156 | \r | |
157 | /*\r | |
158 | * System call glue.\r | |
159 | */\r | |
160 | #define SYSCALLNUM(name) ___CONCAT(SYS_,name)\r | |
161 | \r | |
162 | #define CALLSYS_NOERROR(name) \\r | |
163 | { .mmi ; \\r | |
164 | alloc r9 = ar.pfs, 0, 0, 8, 0 ; \\r | |
165 | mov r31 = ar.k5 ; \\r | |
166 | mov r10 = b0 ;; } \\r | |
167 | { .mib ; \\r | |
168 | mov r8 = SYSCALLNUM(name) ; \\r | |
169 | mov b7 = r31 ; \\r | |
170 | br.call.sptk b0 = b7 ;; }\r | |
171 | \r | |
172 | \r | |
173 | /*\r | |
174 | * WEAK_ALIAS: create a weak alias (ELF only).\r | |
175 | */\r | |
176 | #define WEAK_ALIAS(alias,sym) \\r | |
177 | .weak alias; \\r | |
178 | alias = sym\r | |
179 | \r | |
180 | /*\r | |
181 | * STRONG_ALIAS: create a strong alias.\r | |
182 | */\r | |
183 | #define STRONG_ALIAS(alias,sym) \\r | |
184 | .globl alias; \\r | |
185 | alias = sym\r |