]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/architecture/ppc/pseudo_inst.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) 1996 NeXT Software, Inc. All rights reserved.
30 * File: architecture/ppc/pseudo_inst.h
31 * Author: Mike DeMoney
33 * This header file defines assembler pseudo-instruction macros for
36 * NOTE: This is obviously only useful to include in assembly
39 * ALSO NOTE: These macros don't attempt to be 64-bit compatable
42 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
44 * 05-Nov-92 Mike DeMoney (mike@next.com)
48 #ifndef _ARCH_PPC_PSEUDO_INST_H_
49 #define _ARCH_PPC_PSEUDO_INST_H_
51 #include <architecture/ppc/reg_help.h>
52 #include <architecture/ppc/asm_help.h>
57 * Pseudo instruction definitions
61 * Macro package initialization
63 .set __no_at
,0 /* allow at by default */
66 * .at_off -- disable use of at by macros
67 * .at_on -- enable use of at by macros
80 * Load 32-bit immediate into rD
81 * FIXME: Need a way to undefine built-in macro for this.
83 .macro li32
// li32 rD,immed
85 .abort
"invalid operands of li32"
93 .elseif ($
1 & 0xffff) == 0
95 .elseif ($
1 & 0xffff8000) == 0
97 .elseif ($
1 & 0xffff8000) == 0xffff8000
107 * andi32. rD,rS1,IMMED
109 * Perform "andi." with (possibly) 32-bit immediate
111 .macro andi32
. // andi32. rD,rS1,IMMED
113 .abort
"invalid operands of andi."
121 .elseif ($
2 & 0xffff0000) == 0
123 .elseif ($
2 & 0xffff) == 0
124 andis
. $
0,$
1,hi16($
2)
130 .if __no_at
& __used_at
131 .abort
"Macro uses at while .no_at in effect"
138 * Perform "ori" with (possibly) 32-bit immediate
140 .macro ori32
// ori32 rD,rS1,IMMED
142 .abort
"invalid operands of ori"
148 .elseif ($
2 & 0xffff0000) == 0
150 .elseif ($
2 & 0xffff) == 0
159 * xori32 rD,rS1,IMMED
161 * Perform "xor" with (possibly) 32-bit immediate
163 .macro xori32
// xori32 rD,rS1,IMMED
165 .abort
"invalid operands of xori"
171 .elseif ($
2 & 0xffff0000) == 0
173 .elseif ($
2 & 0xffff) == 0
183 * MEMREF_INST -- macros to memory referencing instructions
184 * "capable" of dealing with 32 bit offsets.
186 * NOTE: Because the assembler doesn't have any mechanism for easily
187 * parsing the d(rS) syntax of register-displacement form instructions,
188 * these instructions do NOT mirror the normal memory reference
189 * instructions. The following "transformation" is used:
193 * I.e.: "32" is appended to the instruction name and the base register
194 * and displacement become the 2'nd and 3'rd comma-separated operands.
200 * are also recognized and the missing operand is assumed 0.
202 * ALSO NOTE: r0 or zt should never be used as rS in these instructions.
203 * Use "0" as rS in this case.
205 #define MEMREF_INST(op) \
209 .greg __is_greg,$1 @\
212 .if ($2 & 0xffff8000) == 0 @\
214 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
220 op $0,lo16($2)(at) @\
225 op $0,lo16($2)(at) @\
232 op $0,lo16($2)(at) @\
237 op $0,lo16($2)(at) @\
241 .greg __is_greg,$1 @\
245 .if ($1 & 0xffff8000) == 0 @\
247 .elseif ($1 & 0xffff8000) == 0xffff8000 @\
252 op $0,lo16($1)(at) @\
257 op $0,lo16($1)(at) @\
263 .abort "Invalid operands of " #op "32" @\
265 .if __no_at & __used_at @\
266 .abort "Macro uses at while .no_at in effect" @\
288 * ARITH_INST -- define 32-bit immediate forms of arithmetic
291 * E.g. addi32 rD,rS,IMMED
293 #define ARITH_INST(op, op3, sf) \
294 .macro op ## 32 ## sf @\
296 .abort "invalid operands to " #op "32" @\
300 .if ($2 & 0xffff8000) == 0 @\
302 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
305 .abort "Macro uses at while .no_at in effect" @\
311 .abort "Macro uses at while .no_at in effect" @\
318 ARITH_INST(addi
, add
, )
319 ARITH_INST(subi
, sub
, )
320 ARITH_INST(addic
, addc
, )
321 ARITH_INST(subic
, subc
, )
322 ARITH_INST(addic
, addc
, .)
323 ARITH_INST(subic
, subc
, .)
324 ARITH_INST(mulli
, mull
, )
327 * CMPEX_INST -- define 32-bit immediate forms of extended compare
330 * E.g. cmpwi32 cr3,rS,IMMED
333 #define CMPEX_INST(op, op3) \
338 .if ($2 & 0xffff8000) == 0 @\
340 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
343 .abort "Macro uses at while .no_at in effect" @\
349 .abort "Macro uses at while .no_at in effect" @\
357 .if ($1 & 0xffff8000) == 0 @\
359 .elseif ($1 & 0xffff8000) == 0xffff8000 @\
362 .abort "Macro uses at while .no_at in effect" @\
368 .abort "Macro uses at while .no_at in effect" @\
374 .abort "invalid operands to " #op "32" @\
378 CMPEX_INST(cmpdi
, cmpd
)
379 CMPEX_INST(cmpwi
, cmpw
)
380 CMPEX_INST(cmpldi
, cmpld
)
381 CMPEX_INST(cmplwi
, cmplw
)
384 * CMP_INST -- define 32-bit immediate forms of standard compare
387 * E.g. cmpi32 cr3,0,rS,IMMED
389 #define CMP_INST(op, op3) \
394 .if ($3 & 0xffff8000) == 0 @\
396 .elseif ($3 & 0xffff8000) == 0xffff8000 @\
399 .abort "Macro uses at while .no_at in effect" @\
405 .abort "Macro uses at while .no_at in effect" @\
411 .abort "invalid operands to " #op "32" @\
416 CMP_INST(cmpli
, cmpl
)
418 #endif /* __ASSEMBLER__ */
420 #endif /* _ARCH_PPC_PSEUDO_INST_H_ */