]>
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 * 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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 /* Copyright (c) 1996 NeXT Software, Inc. All rights reserved.
25 * File: architecture/ppc/pseudo_inst.h
26 * Author: Mike DeMoney
28 * This header file defines assembler pseudo-instruction macros for
31 * NOTE: This is obviously only useful to include in assembly
34 * ALSO NOTE: These macros don't attempt to be 64-bit compatable
37 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
39 * 05-Nov-92 Mike DeMoney (mike@next.com)
43 #ifndef _ARCH_PPC_PSEUDO_INST_H_
44 #define _ARCH_PPC_PSEUDO_INST_H_
46 #include <architecture/ppc/reg_help.h>
47 #include <architecture/ppc/asm_help.h>
52 * Pseudo instruction definitions
56 * Macro package initialization
58 .set __no_at
,0 /* allow at by default */
61 * .at_off -- disable use of at by macros
62 * .at_on -- enable use of at by macros
75 * Load 32-bit immediate into rD
76 * FIXME: Need a way to undefine built-in macro for this.
78 .macro li32
// li32 rD,immed
80 .abort
"invalid operands of li32"
88 .elseif ($
1 & 0xffff) == 0
90 .elseif ($
1 & 0xffff8000) == 0
92 .elseif ($
1 & 0xffff8000) == 0xffff8000
102 * andi32. rD,rS1,IMMED
104 * Perform "andi." with (possibly) 32-bit immediate
106 .macro andi32
. // andi32. rD,rS1,IMMED
108 .abort
"invalid operands of andi."
116 .elseif ($
2 & 0xffff0000) == 0
118 .elseif ($
2 & 0xffff) == 0
119 andis
. $
0,$
1,hi16($
2)
125 .if __no_at
& __used_at
126 .abort
"Macro uses at while .no_at in effect"
133 * Perform "ori" with (possibly) 32-bit immediate
135 .macro ori32
// ori32 rD,rS1,IMMED
137 .abort
"invalid operands of ori"
143 .elseif ($
2 & 0xffff0000) == 0
145 .elseif ($
2 & 0xffff) == 0
154 * xori32 rD,rS1,IMMED
156 * Perform "xor" with (possibly) 32-bit immediate
158 .macro xori32
// xori32 rD,rS1,IMMED
160 .abort
"invalid operands of xori"
166 .elseif ($
2 & 0xffff0000) == 0
168 .elseif ($
2 & 0xffff) == 0
178 * MEMREF_INST -- macros to memory referencing instructions
179 * "capable" of dealing with 32 bit offsets.
181 * NOTE: Because the assembler doesn't have any mechanism for easily
182 * parsing the d(rS) syntax of register-displacement form instructions,
183 * these instructions do NOT mirror the normal memory reference
184 * instructions. The following "transformation" is used:
188 * I.e.: "32" is appended to the instruction name and the base register
189 * and displacement become the 2'nd and 3'rd comma-separated operands.
195 * are also recognized and the missing operand is assumed 0.
197 * ALSO NOTE: r0 or zt should never be used as rS in these instructions.
198 * Use "0" as rS in this case.
200 #define MEMREF_INST(op) \
204 .greg __is_greg,$1 @\
207 .if ($2 & 0xffff8000) == 0 @\
209 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
215 op $0,lo16($2)(at) @\
220 op $0,lo16($2)(at) @\
227 op $0,lo16($2)(at) @\
232 op $0,lo16($2)(at) @\
236 .greg __is_greg,$1 @\
240 .if ($1 & 0xffff8000) == 0 @\
242 .elseif ($1 & 0xffff8000) == 0xffff8000 @\
247 op $0,lo16($1)(at) @\
252 op $0,lo16($1)(at) @\
258 .abort "Invalid operands of " #op "32" @\
260 .if __no_at & __used_at @\
261 .abort "Macro uses at while .no_at in effect" @\
283 * ARITH_INST -- define 32-bit immediate forms of arithmetic
286 * E.g. addi32 rD,rS,IMMED
288 #define ARITH_INST(op, op3, sf) \
289 .macro op ## 32 ## sf @\
291 .abort "invalid operands to " #op "32" @\
295 .if ($2 & 0xffff8000) == 0 @\
297 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
300 .abort "Macro uses at while .no_at in effect" @\
306 .abort "Macro uses at while .no_at in effect" @\
313 ARITH_INST(addi
, add
, )
314 ARITH_INST(subi
, sub
, )
315 ARITH_INST(addic
, addc
, )
316 ARITH_INST(subic
, subc
, )
317 ARITH_INST(addic
, addc
, .)
318 ARITH_INST(subic
, subc
, .)
319 ARITH_INST(mulli
, mull
, )
322 * CMPEX_INST -- define 32-bit immediate forms of extended compare
325 * E.g. cmpwi32 cr3,rS,IMMED
328 #define CMPEX_INST(op, op3) \
333 .if ($2 & 0xffff8000) == 0 @\
335 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
338 .abort "Macro uses at while .no_at in effect" @\
344 .abort "Macro uses at while .no_at in effect" @\
352 .if ($1 & 0xffff8000) == 0 @\
354 .elseif ($1 & 0xffff8000) == 0xffff8000 @\
357 .abort "Macro uses at while .no_at in effect" @\
363 .abort "Macro uses at while .no_at in effect" @\
369 .abort "invalid operands to " #op "32" @\
373 CMPEX_INST(cmpdi
, cmpd
)
374 CMPEX_INST(cmpwi
, cmpw
)
375 CMPEX_INST(cmpldi
, cmpld
)
376 CMPEX_INST(cmplwi
, cmplw
)
379 * CMP_INST -- define 32-bit immediate forms of standard compare
382 * E.g. cmpi32 cr3,0,rS,IMMED
384 #define CMP_INST(op, op3) \
389 .if ($3 & 0xffff8000) == 0 @\
391 .elseif ($3 & 0xffff8000) == 0xffff8000 @\
394 .abort "Macro uses at while .no_at in effect" @\
400 .abort "Macro uses at while .no_at in effect" @\
406 .abort "invalid operands to " #op "32" @\
411 CMP_INST(cmpli
, cmpl
)
413 #endif /* __ASSEMBLER__ */
415 #endif /* _ARCH_PPC_PSEUDO_INST_H_ */