]>
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 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 /* Copyright (c) 1996 NeXT Software, Inc. All rights reserved.
24 * File: architecture/ppc/pseudo_inst.h
25 * Author: Mike DeMoney
27 * This header file defines assembler pseudo-instruction macros for
30 * NOTE: This is obviously only useful to include in assembly
33 * ALSO NOTE: These macros don't attempt to be 64-bit compatable
36 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
38 * 05-Nov-92 Mike DeMoney (mike@next.com)
42 #ifndef _ARCH_PPC_PSEUDO_INST_H_
43 #define _ARCH_PPC_PSEUDO_INST_H_
45 #include <architecture/ppc/reg_help.h>
46 #include <architecture/ppc/asm_help.h>
51 * Pseudo instruction definitions
55 * Macro package initialization
57 .set __no_at
,0 /* allow at by default */
60 * .at_off -- disable use of at by macros
61 * .at_on -- enable use of at by macros
74 * Load 32-bit immediate into rD
75 * FIXME: Need a way to undefine built-in macro for this.
77 .macro li32
// li32 rD,immed
79 .abort
"invalid operands of li32"
87 .elseif ($
1 & 0xffff) == 0
89 .elseif ($
1 & 0xffff8000) == 0
91 .elseif ($
1 & 0xffff8000) == 0xffff8000
101 * andi32. rD,rS1,IMMED
103 * Perform "andi." with (possibly) 32-bit immediate
105 .macro andi32
. // andi32. rD,rS1,IMMED
107 .abort
"invalid operands of andi."
115 .elseif ($
2 & 0xffff0000) == 0
117 .elseif ($
2 & 0xffff) == 0
118 andis
. $
0,$
1,hi16($
2)
124 .if __no_at
& __used_at
125 .abort
"Macro uses at while .no_at in effect"
132 * Perform "ori" with (possibly) 32-bit immediate
134 .macro ori32
// ori32 rD,rS1,IMMED
136 .abort
"invalid operands of ori"
142 .elseif ($
2 & 0xffff0000) == 0
144 .elseif ($
2 & 0xffff) == 0
153 * xori32 rD,rS1,IMMED
155 * Perform "xor" with (possibly) 32-bit immediate
157 .macro xori32
// xori32 rD,rS1,IMMED
159 .abort
"invalid operands of xori"
165 .elseif ($
2 & 0xffff0000) == 0
167 .elseif ($
2 & 0xffff) == 0
177 * MEMREF_INST -- macros to memory referencing instructions
178 * "capable" of dealing with 32 bit offsets.
180 * NOTE: Because the assembler doesn't have any mechanism for easily
181 * parsing the d(rS) syntax of register-displacement form instructions,
182 * these instructions do NOT mirror the normal memory reference
183 * instructions. The following "transformation" is used:
187 * I.e.: "32" is appended to the instruction name and the base register
188 * and displacement become the 2'nd and 3'rd comma-separated operands.
194 * are also recognized and the missing operand is assumed 0.
196 * ALSO NOTE: r0 or zt should never be used as rS in these instructions.
197 * Use "0" as rS in this case.
199 #define MEMREF_INST(op) \
203 .greg __is_greg,$1 @\
206 .if ($2 & 0xffff8000) == 0 @\
208 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
214 op $0,lo16($2)(at) @\
219 op $0,lo16($2)(at) @\
226 op $0,lo16($2)(at) @\
231 op $0,lo16($2)(at) @\
235 .greg __is_greg,$1 @\
239 .if ($1 & 0xffff8000) == 0 @\
241 .elseif ($1 & 0xffff8000) == 0xffff8000 @\
246 op $0,lo16($1)(at) @\
251 op $0,lo16($1)(at) @\
257 .abort "Invalid operands of " #op "32" @\
259 .if __no_at & __used_at @\
260 .abort "Macro uses at while .no_at in effect" @\
282 * ARITH_INST -- define 32-bit immediate forms of arithmetic
285 * E.g. addi32 rD,rS,IMMED
287 #define ARITH_INST(op, op3, sf) \
288 .macro op ## 32 ## sf @\
290 .abort "invalid operands to " #op "32" @\
294 .if ($2 & 0xffff8000) == 0 @\
296 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
299 .abort "Macro uses at while .no_at in effect" @\
305 .abort "Macro uses at while .no_at in effect" @\
312 ARITH_INST(addi
, add
, )
313 ARITH_INST(subi
, sub
, )
314 ARITH_INST(addic
, addc
, )
315 ARITH_INST(subic
, subc
, )
316 ARITH_INST(addic
, addc
, .)
317 ARITH_INST(subic
, subc
, .)
318 ARITH_INST(mulli
, mull
, )
321 * CMPEX_INST -- define 32-bit immediate forms of extended compare
324 * E.g. cmpwi32 cr3,rS,IMMED
327 #define CMPEX_INST(op, op3) \
332 .if ($2 & 0xffff8000) == 0 @\
334 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
337 .abort "Macro uses at while .no_at in effect" @\
343 .abort "Macro uses at while .no_at in effect" @\
351 .if ($1 & 0xffff8000) == 0 @\
353 .elseif ($1 & 0xffff8000) == 0xffff8000 @\
356 .abort "Macro uses at while .no_at in effect" @\
362 .abort "Macro uses at while .no_at in effect" @\
368 .abort "invalid operands to " #op "32" @\
372 CMPEX_INST(cmpdi
, cmpd
)
373 CMPEX_INST(cmpwi
, cmpw
)
374 CMPEX_INST(cmpldi
, cmpld
)
375 CMPEX_INST(cmplwi
, cmplw
)
378 * CMP_INST -- define 32-bit immediate forms of standard compare
381 * E.g. cmpi32 cr3,0,rS,IMMED
383 #define CMP_INST(op, op3) \
388 .if ($3 & 0xffff8000) == 0 @\
390 .elseif ($3 & 0xffff8000) == 0xffff8000 @\
393 .abort "Macro uses at while .no_at in effect" @\
399 .abort "Macro uses at while .no_at in effect" @\
405 .abort "invalid operands to " #op "32" @\
410 CMP_INST(cmpli
, cmpl
)
412 #endif /* __ASSEMBLER__ */
414 #endif /* _ARCH_PPC_PSEUDO_INST_H_ */