]>
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_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* Copyright (c) 1996 NeXT Software, Inc. All rights reserved.
27 * File: architecture/ppc/pseudo_inst.h
28 * Author: Mike DeMoney
30 * This header file defines assembler pseudo-instruction macros for
33 * NOTE: This is obviously only useful to include in assembly
36 * ALSO NOTE: These macros don't attempt to be 64-bit compatable
39 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
41 * 05-Nov-92 Mike DeMoney (mike@next.com)
45 #ifndef _ARCH_PPC_PSEUDO_INST_H_
46 #define _ARCH_PPC_PSEUDO_INST_H_
48 #include <architecture/ppc/reg_help.h>
49 #include <architecture/ppc/asm_help.h>
54 * Pseudo instruction definitions
58 * Macro package initialization
60 .set __no_at
,0 /* allow at by default */
63 * .at_off -- disable use of at by macros
64 * .at_on -- enable use of at by macros
77 * Load 32-bit immediate into rD
78 * FIXME: Need a way to undefine built-in macro for this.
80 .macro li32
// li32 rD,immed
82 .abort
"invalid operands of li32"
90 .elseif ($
1 & 0xffff) == 0
92 .elseif ($
1 & 0xffff8000) == 0
94 .elseif ($
1 & 0xffff8000) == 0xffff8000
104 * andi32. rD,rS1,IMMED
106 * Perform "andi." with (possibly) 32-bit immediate
108 .macro andi32
. // andi32. rD,rS1,IMMED
110 .abort
"invalid operands of andi."
118 .elseif ($
2 & 0xffff0000) == 0
120 .elseif ($
2 & 0xffff) == 0
121 andis
. $
0,$
1,hi16($
2)
127 .if __no_at
& __used_at
128 .abort
"Macro uses at while .no_at in effect"
135 * Perform "ori" with (possibly) 32-bit immediate
137 .macro ori32
// ori32 rD,rS1,IMMED
139 .abort
"invalid operands of ori"
145 .elseif ($
2 & 0xffff0000) == 0
147 .elseif ($
2 & 0xffff) == 0
156 * xori32 rD,rS1,IMMED
158 * Perform "xor" with (possibly) 32-bit immediate
160 .macro xori32
// xori32 rD,rS1,IMMED
162 .abort
"invalid operands of xori"
168 .elseif ($
2 & 0xffff0000) == 0
170 .elseif ($
2 & 0xffff) == 0
180 * MEMREF_INST -- macros to memory referencing instructions
181 * "capable" of dealing with 32 bit offsets.
183 * NOTE: Because the assembler doesn't have any mechanism for easily
184 * parsing the d(rS) syntax of register-displacement form instructions,
185 * these instructions do NOT mirror the normal memory reference
186 * instructions. The following "transformation" is used:
190 * I.e.: "32" is appended to the instruction name and the base register
191 * and displacement become the 2'nd and 3'rd comma-separated operands.
197 * are also recognized and the missing operand is assumed 0.
199 * ALSO NOTE: r0 or zt should never be used as rS in these instructions.
200 * Use "0" as rS in this case.
202 #define MEMREF_INST(op) \
206 .greg __is_greg,$1 @\
209 .if ($2 & 0xffff8000) == 0 @\
211 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
217 op $0,lo16($2)(at) @\
222 op $0,lo16($2)(at) @\
229 op $0,lo16($2)(at) @\
234 op $0,lo16($2)(at) @\
238 .greg __is_greg,$1 @\
242 .if ($1 & 0xffff8000) == 0 @\
244 .elseif ($1 & 0xffff8000) == 0xffff8000 @\
249 op $0,lo16($1)(at) @\
254 op $0,lo16($1)(at) @\
260 .abort "Invalid operands of " #op "32" @\
262 .if __no_at & __used_at @\
263 .abort "Macro uses at while .no_at in effect" @\
285 * ARITH_INST -- define 32-bit immediate forms of arithmetic
288 * E.g. addi32 rD,rS,IMMED
290 #define ARITH_INST(op, op3, sf) \
291 .macro op ## 32 ## sf @\
293 .abort "invalid operands to " #op "32" @\
297 .if ($2 & 0xffff8000) == 0 @\
299 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
302 .abort "Macro uses at while .no_at in effect" @\
308 .abort "Macro uses at while .no_at in effect" @\
315 ARITH_INST(addi
, add
, )
316 ARITH_INST(subi
, sub
, )
317 ARITH_INST(addic
, addc
, )
318 ARITH_INST(subic
, subc
, )
319 ARITH_INST(addic
, addc
, .)
320 ARITH_INST(subic
, subc
, .)
321 ARITH_INST(mulli
, mull
, )
324 * CMPEX_INST -- define 32-bit immediate forms of extended compare
327 * E.g. cmpwi32 cr3,rS,IMMED
330 #define CMPEX_INST(op, op3) \
335 .if ($2 & 0xffff8000) == 0 @\
337 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
340 .abort "Macro uses at while .no_at in effect" @\
346 .abort "Macro uses at while .no_at in effect" @\
354 .if ($1 & 0xffff8000) == 0 @\
356 .elseif ($1 & 0xffff8000) == 0xffff8000 @\
359 .abort "Macro uses at while .no_at in effect" @\
365 .abort "Macro uses at while .no_at in effect" @\
371 .abort "invalid operands to " #op "32" @\
375 CMPEX_INST(cmpdi
, cmpd
)
376 CMPEX_INST(cmpwi
, cmpw
)
377 CMPEX_INST(cmpldi
, cmpld
)
378 CMPEX_INST(cmplwi
, cmplw
)
381 * CMP_INST -- define 32-bit immediate forms of standard compare
384 * E.g. cmpi32 cr3,0,rS,IMMED
386 #define CMP_INST(op, op3) \
391 .if ($3 & 0xffff8000) == 0 @\
393 .elseif ($3 & 0xffff8000) == 0xffff8000 @\
396 .abort "Macro uses at while .no_at in effect" @\
402 .abort "Macro uses at while .no_at in effect" @\
408 .abort "invalid operands to " #op "32" @\
413 CMP_INST(cmpli
, cmpl
)
415 #endif /* __ASSEMBLER__ */
417 #endif /* _ARCH_PPC_PSEUDO_INST_H_ */