]>
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_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1996 NeXT Software, Inc. All rights reserved.
32 * File: architecture/ppc/pseudo_inst.h
33 * Author: Mike DeMoney
35 * This header file defines assembler pseudo-instruction macros for
38 * NOTE: This is obviously only useful to include in assembly
41 * ALSO NOTE: These macros don't attempt to be 64-bit compatable
44 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
46 * 05-Nov-92 Mike DeMoney (mike@next.com)
50 #ifndef _ARCH_PPC_PSEUDO_INST_H_
51 #define _ARCH_PPC_PSEUDO_INST_H_
53 #include <architecture/ppc/reg_help.h>
54 #include <architecture/ppc/asm_help.h>
59 * Pseudo instruction definitions
63 * Macro package initialization
65 .set __no_at
,0 /* allow at by default */
68 * .at_off -- disable use of at by macros
69 * .at_on -- enable use of at by macros
82 * Load 32-bit immediate into rD
83 * FIXME: Need a way to undefine built-in macro for this.
85 .macro li32
// li32 rD,immed
87 .abort
"invalid operands of li32"
95 .elseif ($
1 & 0xffff) == 0
97 .elseif ($
1 & 0xffff8000) == 0
99 .elseif ($
1 & 0xffff8000) == 0xffff8000
109 * andi32. rD,rS1,IMMED
111 * Perform "andi." with (possibly) 32-bit immediate
113 .macro andi32
. // andi32. rD,rS1,IMMED
115 .abort
"invalid operands of andi."
123 .elseif ($
2 & 0xffff0000) == 0
125 .elseif ($
2 & 0xffff) == 0
126 andis
. $
0,$
1,hi16($
2)
132 .if __no_at
& __used_at
133 .abort
"Macro uses at while .no_at in effect"
140 * Perform "ori" with (possibly) 32-bit immediate
142 .macro ori32
// ori32 rD,rS1,IMMED
144 .abort
"invalid operands of ori"
150 .elseif ($
2 & 0xffff0000) == 0
152 .elseif ($
2 & 0xffff) == 0
161 * xori32 rD,rS1,IMMED
163 * Perform "xor" with (possibly) 32-bit immediate
165 .macro xori32
// xori32 rD,rS1,IMMED
167 .abort
"invalid operands of xori"
173 .elseif ($
2 & 0xffff0000) == 0
175 .elseif ($
2 & 0xffff) == 0
185 * MEMREF_INST -- macros to memory referencing instructions
186 * "capable" of dealing with 32 bit offsets.
188 * NOTE: Because the assembler doesn't have any mechanism for easily
189 * parsing the d(rS) syntax of register-displacement form instructions,
190 * these instructions do NOT mirror the normal memory reference
191 * instructions. The following "transformation" is used:
195 * I.e.: "32" is appended to the instruction name and the base register
196 * and displacement become the 2'nd and 3'rd comma-separated operands.
202 * are also recognized and the missing operand is assumed 0.
204 * ALSO NOTE: r0 or zt should never be used as rS in these instructions.
205 * Use "0" as rS in this case.
207 #define MEMREF_INST(op) \
211 .greg __is_greg,$1 @\
214 .if ($2 & 0xffff8000) == 0 @\
216 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
222 op $0,lo16($2)(at) @\
227 op $0,lo16($2)(at) @\
234 op $0,lo16($2)(at) @\
239 op $0,lo16($2)(at) @\
243 .greg __is_greg,$1 @\
247 .if ($1 & 0xffff8000) == 0 @\
249 .elseif ($1 & 0xffff8000) == 0xffff8000 @\
254 op $0,lo16($1)(at) @\
259 op $0,lo16($1)(at) @\
265 .abort "Invalid operands of " #op "32" @\
267 .if __no_at & __used_at @\
268 .abort "Macro uses at while .no_at in effect" @\
290 * ARITH_INST -- define 32-bit immediate forms of arithmetic
293 * E.g. addi32 rD,rS,IMMED
295 #define ARITH_INST(op, op3, sf) \
296 .macro op ## 32 ## sf @\
298 .abort "invalid operands to " #op "32" @\
302 .if ($2 & 0xffff8000) == 0 @\
304 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
307 .abort "Macro uses at while .no_at in effect" @\
313 .abort "Macro uses at while .no_at in effect" @\
320 ARITH_INST(addi
, add
, )
321 ARITH_INST(subi
, sub
, )
322 ARITH_INST(addic
, addc
, )
323 ARITH_INST(subic
, subc
, )
324 ARITH_INST(addic
, addc
, .)
325 ARITH_INST(subic
, subc
, .)
326 ARITH_INST(mulli
, mull
, )
329 * CMPEX_INST -- define 32-bit immediate forms of extended compare
332 * E.g. cmpwi32 cr3,rS,IMMED
335 #define CMPEX_INST(op, op3) \
340 .if ($2 & 0xffff8000) == 0 @\
342 .elseif ($2 & 0xffff8000) == 0xffff8000 @\
345 .abort "Macro uses at while .no_at in effect" @\
351 .abort "Macro uses at while .no_at in effect" @\
359 .if ($1 & 0xffff8000) == 0 @\
361 .elseif ($1 & 0xffff8000) == 0xffff8000 @\
364 .abort "Macro uses at while .no_at in effect" @\
370 .abort "Macro uses at while .no_at in effect" @\
376 .abort "invalid operands to " #op "32" @\
380 CMPEX_INST(cmpdi
, cmpd
)
381 CMPEX_INST(cmpwi
, cmpw
)
382 CMPEX_INST(cmpldi
, cmpld
)
383 CMPEX_INST(cmplwi
, cmplw
)
386 * CMP_INST -- define 32-bit immediate forms of standard compare
389 * E.g. cmpi32 cr3,0,rS,IMMED
391 #define CMP_INST(op, op3) \
396 .if ($3 & 0xffff8000) == 0 @\
398 .elseif ($3 & 0xffff8000) == 0xffff8000 @\
401 .abort "Macro uses at while .no_at in effect" @\
407 .abort "Macro uses at while .no_at in effect" @\
413 .abort "invalid operands to " #op "32" @\
418 CMP_INST(cmpli
, cmpl
)
420 #endif /* __ASSEMBLER__ */
422 #endif /* _ARCH_PPC_PSEUDO_INST_H_ */