Variable-Length Encoding (VLE) Extension Programming Interface Manual
Variable-Length Encoding (VLE) Extension Programming Interface Manual
Extension Programming
Interface Manual
VLEPIM
Rev. 1, 2/2006
How to Reach Us:
Home Page:
www.freescale.com
email:
[email protected]
USA/Europe or Locations Not Listed:
Freescale Semiconductor
Technical Information Center, CH370
1300 N. Alma School Road
Chandler, Arizona 85224
(800) 521-6274
480-768-2130
[email protected]
Europe, Middle East, and Africa:
Freescale Halbleiter Deutschland GmbH
Technical Information Center
Schatzbogen 7
81829 Muenchen, Germany
+44 1296 380 456 (English)
+46 8 52200080 (English) Information in this document is provided solely to enable system and software
+49 89 92103 559 (German) implementers to use Freescale Semiconductor products. There are no express or
+33 1 69 35 48 48 (French) implied copyright licenses granted hereunder to design or fabricate any integrated
[email protected]
circuits or integrated circuits based on the information in this document.
Japan:
Freescale Semiconductor reserves the right to make changes without further notice to
Freescale Semiconductor Japan Ltd.
Headquarters any products herein. Freescale Semiconductor makes no warranty, representation or
ARCO Tower 15F guarantee regarding the suitability of its products for any particular purpose, nor does
1-8-1, Shimo-Meguro, Meguro-ku Freescale Semiconductor assume any liability arising out of the application or use of
Tokyo 153-0064, Japan
any product or circuit, and specifically disclaims any and all liability, including without
0120 191014
+81 3 5437 9125 limitation consequential or incidental damages. “Typical” parameters which may be
[email protected] provided in Freescale Semiconductor data sheets and/or specifications can and do
Asia/Pacific: vary in different applications and actual performance may vary over time. All operating
Freescale Semiconductor Hong Kong Ltd. parameters, including “Typicals” must be validated for each customer application by
Technical Information Center customer’s technical experts. Freescale Semiconductor does not convey any license
2 Dai King Street
under its patent rights nor the rights of others. Freescale Semiconductor products are
Tai Po Industrial Estate,
Tai Po, N.T., Hong Kong not designed, intended, or authorized for use as components in systems intended for
+800 2666 8080 surgical implant into the body, or other applications intended to support or sustain life,
[email protected] or for any other application in which the failure of the Freescale Semiconductor product
For Literature Requests Only: could create a situation where personal injury or death may occur. Should Buyer
Freescale Semiconductor purchase or use Freescale Semiconductor products for any such unintended or
Literature Distribution Center
P.O. Box 5405 unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor
Denver, Colorado 80217 and its officers, employees, subsidiaries, affiliates, and distributors harmless against all
(800) 441-2447 claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
303-675-2140
directly or indirectly, any claim of personal injury or death associated with such
Fax: 303-675-2150
LDCForFreescaleSemiconductor unintended or unauthorized use, even if such claim alleges that Freescale
@hibbertgroup.com Semiconductor was negligent regarding the design or manufacture of the part.
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. The PowerPC
name is a trademark of IBM Corp. and is used under license. All other product or service names are
the property of their respective owners.
© Freescale Semiconductor, Inc., 2006. All rights reserved.
Chapter 1
Overview
Chapter 2
Application Binary Interface (ABI)
Chapter 3
Instruction Set
Appendix A
Simplified Mnemonics for VLE Instructions
Appendix B
Revision History
Audience
This manual is for system software and application programmers who want to develop products using the
VLE extension. An understanding of operating systems, microprocessor system design, the basic
principles of RISC processing, and the VLE instruction set is assumed.
Organization
Following is a summary of the major sections of this manual:
• Chapter 1, “Overview,” provides a general understanding of what the programming model defines
in the VLE extension.
• Chapter 2, “Application Binary Interface (ABI),” describes the VLE extensions for the PowerPC™
e500 Application Binary Interface (e500 ABI) to support VLE technology.
• Chapter 3, “Instruction Set,” provides an overview of the VLE instruction set architecture. For a
detailed description of each instruction, including assembly language syntax, refer to the VLE
section of the EREF.
• Appendix A, “Simplified Mnemonics for VLE Instructions,” describes simplified mnemonics,
which are provided for easier coding of assembly language programs using VLE technology.
Suggested Reading
This section lists background reading for this manual as well as general information on the VLE extension
and PowerPC architecture.
General Information
The following documentation, published by Morgan-Kaufmann Publishers, 340 Pine Street, Sixth
Floor, San Francisco, CA, provides useful information on the PowerPC architecture and computer
architecture in general:
• The PowerPC Architecture: A Specification for a New Family of RISC Processors, Second
Edition, by International Business Machines, Inc.
For updates to the specification, see http://www.austin.ibm.com/tech/ppc-chg.html.
• Computer Architecture: A Quantitative Approach, Third Edition, by John L. Hennessy and
David A. Patterson
• Computer Organization and Design: The Hardware/Software Interface, Second Edition,
David A. Patterson and John L. Hennessy
Conventions
This document uses the following notational conventions:
cleared/set When a bit takes the value zero, it is said to be cleared; when it takes a value of
one, it is said to be set.
mnemonics Instruction mnemonics are shown in lowercase bold.
Terminology Conventions
Table i lists certain terms used in this manual that differ from the architecture terminology conventions.
Table i. Terminology Conventions
Architecture Specification This Manual
Relocation Translation
Term Meaning
CR Condition register
EA Effective address
L2 Secondary cache
LIFO Last-in-first-out
LR Link register
No-op No operation
Term Meaning
VA Virtual address
XER Register used primarily for indicating conditions such as carries and overflows for integer operations
type
data
For the .PPC.EMB.apuinfo section, the name is APUinfo, the type is 2 (as type 1 is already reserved), and
the data contains a series of words providing information about the APU or extension, one per word. The
information contains two unsigned half words: the upper half contains the unique identifier, and the lower
half contains the revision number. The VLE identifier is shown in Table 2-1.
Table 2-1. VLE Identifier
0x0104 VLE
Linkers merge all .PPC.EMB.apuinfo sections in individual object files into one, with merging of per-APU
information. For example, after linking file a.o and b.o, the merged .PPC.EMB.apuinfo is as shown in
Example 2-3.
Example 2-3. PPC.EMB.apuinfo:
0 0x00000008 # 8 bytes in "APUinfo\0"
4 0x0000000C # 12 bytes (3 words) of APU information
8 0x00000002 # NOTE type 2
12 0x41505569 # ASCII for "APUi"
16 0x6e666f00 # ASCII for "nfo\0"
20 0x00010002 # APU #1, revision 2
24 0x01040001 # VLE, revision 1
28 0x00040001 # APU #4, revision 1
Note that it is assumed that a later revision of any APU or extension is compatible with an earlier one, but
not vice versa. Thus, the resultant .PPC.EMB.apuinfo section requires APU #1 revision 2 or greater to
work, and does not work on APU #1 revision 1. If a revision breaks backwards compatibility, it must be
given a new unique identifier.
A linker may optionally warn when different objects require different revisions, because moving the
revision up may make the executable no longer work on processors with the older revision. In this
example, the linker could emit a warning like “Warning: bumping APU #1 revision number to 2, required
by b.o.”
The SHF_PPC_VLE flag marks ELF sections containing VLE instructions. Similarly, the PF_PPC_VLE
flag is used by ELF program headers to mark program sections containing VLE instructions. If either the
SHF_PPC_VLE flag or the PF_PPC_VLE flag is set, then instructions in those marked sections are
interpreted as VLE instructions; Book E instructions reside in sections that do not have these flags set.
ELF sections setting the SHF_PPC_VLE flag that contain VLE instructions should also use the
SHF_ALLOC and SHF_EXECINSTR bits as necessary. Setting the SHF_PPC_VLE bit does not
automatically imply a section that is marked as allocate (SHF_ALLOC) or executable
(SHF_EXECINSTR). The linker keeps sections marked as VLE (SHF_PPC_VLE) in separate output
sections that do not contain Book E instructions.
Similarly, ELF program headers setting the PF_PPC_VLE flag should use the PF_X, PF_W, and PF_R
flags to indicate executable, writable, or readable attributes. It is considered an error for a program header
with PF_PPC_VLE set to contain sections that do not have SHF_PPC_VLE set.
A program loader or debugger can then scan the section headers or program headers to detect VLE sections
in case anything special is required for section processing or downloading.
0 10 11 31
low21
— low21
0 5 6 10 11 15 16 17 20 21 31
split20
011100 — split204:8 0 split200:3 split209:19
0 10 11 15 16 20 21 31
split16a
— split16a0:4 — split16a5:15
0 5 6 10 11 20 21 31
split16d
— split16d0:4 — split16d5:15
0 6 7 30 31
bdh24
— bdh24 —
0 15 16 30 31
bdh15
— bdh15 —
0 7 8 15
bdh8
— bdh8
Table 2-2 describes the additional relocation fields required by VLE instructions.
Table 2-2. VLE Relocation Field Descriptions
Field Descriptions
split20 20-bit field with the 4 msbs occupying bits 17–20, the next 5 bits occupying bits 11–15, and the remaining 11 bits
occupying bits 21–31. In addition, bits 0–5 in the destination word are encoded with the binary value 011100, bit 16
is encoded with the binary value 0.
Note: This relocation field specifies the opcode for the VLE e_li instruction, allowing the linker to force the encoding
of the e_li instruction, potentially changing the user’s specified instruction. This functionality supports small
data area relocation types. (R_PPC_VLE_SDA21 and R_PPC_VLE_SDA21_LO).
split16a 16-bit field with the 5 msbs occupying bits 11–15 (the rA field) and the remaining 11 bits occupying bits 21–31.
split16d 16-bit field with the 5 msbs occupying bits 6–10 (the rD field) and the remaining 11 bits occupying bits 21–31.
bdh24 24-bit field occupying bits 7–30 used to resolve branch displacements to half-word boundaries.
bdh15 15-bit field occupying bits 16–30 used to resolve branch displacements to half-word boundaries.
bdh8 8-bit field occupying bits 8–15 of a half-word. This field is used by a 16-bit branch instruction.
NOTE
Relocation entry types applied to VLE sections use half-word alignment
boundaries, because the VLE instruction architecture mixes 16- and 32-bit
encodings within a VLE section. Book E instruction encodings in non-VLE
sections use e500 ABI alignment specifications.
Calculations in Table 2-4 assume the actions are transforming a relocatable file into either an executable
or a shared object file. Conceptually, the link editor merges one or more relocatable files to form the output.
It determines how to combine and locate the input files, updates the symbol values, and then performs
relocations. Relocations applied to executable or shared object files are similar and accomplish the same
result. The notations used in Table 2-4 are described in Table 2-3.
Table 2-3. Notation Conventions
Field Descriptions
A Represents the addend used to compute the value of the relocatable field.
P Represents the place (section offset or address) of the storage unit being relocated (computed using r_offset).
S Represents the value of the symbol whose index resides in the relocation entry.
X Represents the offset from the appropriate base (_SDA_BASE_, _SDA2_BASE_, or 0) to where the linker placed the
symbol whose index is in r_info.
Y Represents a 5-bit value for the base register for the section where the linker placed the symbol whose index is in r_info.
Acceptable values are: the value 13 for symbols in .sdata or .sbss, the value 2 for symbols in .PPC.EMB.sdata2 or
.PPC.EMB.sbss2, or the value 0 for symbols in .PPC.EMB.sdata0 or .PPC.EMB.sbss0.
Relocation entries apply to half words or words. In either case, the r_offset value designates the offset or
virtual address of the first byte of the affected storage unit. The relocation type specifies which bits to
change and how to calculate their values. Processors that implement the PowerPC architecture use only
the Elf32_Rela relocation entries with explicit addends. For relocation entries, the r_addend member
serves as the relocation addend. In all cases, the offset, addend, and the computed result use the byte order
specified in the ELF header.
The following general rules apply to the interpretation of the relocation types in Table 2-4:
• + and – denote 32-bit modulus addition and subtraction.
|| denotes concatenation of bits or bit fields.
>> denotes arithmetic right-shifting (shifting with sign copying) of the value of the left operand by
the number of bits given by the right operand.
• For relocation types associated with branch displacements, in which the name of the relocation
type contains 8, the upper 24 bits of the computed value before shifting must all be the same (either
all zeros or all ones—that is, sign-extended displacement). For relocation types in which the name
contains 15, the upper 17 bits of the computed value before shifting must all be the same. For
relocation types in which the name contains 24, the upper 7 bits of the computed value before
shifting must all be the same. For relocation types whose names contain 8, 15, or 24, the low 1-bit
of the computed value before shifting must be zero (half-word boundary).
• #hi(value) and #lo(value) denote the 16 msbs and lsbs of the indicated value. That is,
#lo(x)=(x & 0xFFFF) and #hi(x)=((x>>16) & 0xFFFF).
The high-adjusted value, #ha(value), compensates for #lo() being treated as a signed number:
#ha(x)=(((x >> 16) + ((x & 0x8000) ? 1 : 0)) & 0xFFFF).
• _SDA_BASE_ is a symbol defined by the link editor whose value in shared objects is the same as
_GLOBAL_OFFSET_TABLE_, and in executable programs is an address within the small data
area. Similarly, _SDA2_BASE_ is a symbol defined by the link editor whose value in executable
programs is an address within the small data 2 area.
Note that the relocation types in Figure 2-4 apply only to VLE sections. Sections containing Book E
instructions should use the PowerPC e500 Application Binary Interface.
Table 2-4. VLE Relocation Types
Name Description
R_PPC_VLE_SDA211 The linker computes a 21-bit value with the 5 msbs having the value 13 (for GPR13), 2 (for GPR2),
or 0. If the symbol whose index is in r_info is contained in .sdata or .sbss, a linker supplies a value
of 13; if the symbol is in .PPC.EMB.sdata2 or .PPC.EMB.sbss2, the linker supplies a value of 2; if
the symbol is in .PPC.EMB.sdata0 or .PPC.EMB.sbss0, the linker supplies a value of 0; otherwise,
the link fails.
The 16 lsbs of this 21-bit value are set to the address of the symbol plus the relocation entry
r_addend value minus the appropriate base for the symbol section:
• _SDA_BASE_ for a symbol in .sdata or .sbss
• _SDA2_BASE_ for a symbol in .PPC.EMB.sdata2 or .PPC.EMB.sbss2
• 0 for a symbol in .PPC.EMB.sdata0 or .PPC.EMB.sbss0
If the 5 msbs of the computed 21-bit value are non-zero, the linker uses the low21 relocation field,
where the 11 msbs remain unchanged and the computed 21-bit value occupies bits 11–31.
Otherwise, the 5 msbs of the computed 21-bit value are zero, with the following results:
• The linker uses the split20 relocation field, where only bits occupying 6–10 remain unchanged
• The 5 msbs of the 21-bit value are ignored
• The next msb is copied to bit 11 and to bits 17–20 as a sign-extension
• The next 4 msbs are copied to bits 12–15
• The 11 remaining bits are copied to bits 21–31.
• In the destination word, bits 0–5 are encoded with the binary value 011100, and bit 16 is
encoded with the binary value 0.
Note: Use of the split20 relocation field forces the encoding of the VLE e_li instruction, which may
change the user's specified instruction. See Table 2-2.
R_PPC_VLE_SDA21_LO 1 Like R_PPC_VLE_SDA21, except that the #lo() operator obtains the 16 lsbs of the 21-bit value.
The #lo() operator is applied after the address of the symbol plus the relocation entry r_addend
value is calculated, minus the appropriate base for the symbol’s section: _SDA_BASE_ for a
symbol in .sdata or .sbss, _SDA2_BASE_ for a symbol in .PPC.EMB.sdata2 or .PPC.EMB.sbss2,
or 0 for a symbol in .PPC.EMB.sdata0 or .PPC.EMB.sbss0. The R_PPC_VLE_SDA21 entry
describes applying the calculated 21-bit value to the destination word that uses either the low21
relocation field or the split20 relocation field. See Table 2-2.
1
Note that if the opcode is changed, 27 bits are changed instead of 21.
NOTE
The relocations in Table 2-5 are not for load and store instructions (such as,
e_lwz and e_stw), which should use the EABI relocation
R_PPC_EMB_SDA21. These relocations, as written here, only start with an
e_add16i. A linker might convert the instruction to an e_li. Although other
relocations do not specify the instructions they apply to, it may be useful to
know that these relocations can apply only to one instruction.
VLE instruction encodings generally differ from Book E instructions, except that most Book E
instructions falling within Book E primary opcode 31 are encoded identically in 32-bit VLE instructions.
Also, they have identical semantics unless they affect or access a resource not supported by the VLE
extension. Primary opcode 4 is available to support additional instructions using identical encodings for
both Book E and VLE. Therefore, an implementation of VLE can include additional APUs, such as the
cache line locking APU, vector or scalar single-precision floating-point APU, and SPE extension and use
the exact encodings.
The VLE extension does not currently fully encompass 64-bit operations, although the addition of such
operations in a future version is envisioned. For future compatibility, and to avoid confusion with Book E,
register bit numbering remains the same as in traditional Book E.
The description of each instruction is contained in the VLE section of the EREF and includes the
mnemonic and a formatted list of operands. VLE instructions have either exact or similar semantics to
Book E instructions. Where the semantics, side-effects, and binary encodings are identical, the Book E
mnemonics and formats are used. Where the semantics are similar but the binary encodings differ, the
Book E mnemonic is generally preceded with an ‘e_’. To distinguish similar instructions available in both
16- and 32-bit formats under VLE and standard Book E instructions, VLE instructions encoded with 16
bits have an ‘se_’ prefix. VLE instructions encoded with 32 bits that have different binary encodings or
semantics than the equivalent Book E instruction have an ‘e_’ prefix. Some examples are the following:
stw RS,D(RA) // Standard Book E instruction
e_stw RS,D(RA) // 32-bit VLE instruction
se_stw RZ,SD4(RX) // 16-bit VLE instruction
For detailed functional descriptions of each VLE instruction, along with the assembly mnemonic and
operands, refer to the VLE section of the EREF.
A.1 Overview
Simplified (or extended) mnemonics allow an assembly-language programmer to use more intuitive
mnemonics and symbols than the instructions and syntax defined by the instruction set architecture. For
example, to code the conditional call “branch to target if CR3 specifies a greater than condition, setting the
LR” without simplified mnemonics, the programmer would write the branch conditional and link
instruction e_bcl 1,13,target. The simplified mnemonic, branch if greater than and link, e_bgtl cr3,target,
incorporates the conditions. Not only is it easier to remember the symbols than the numbers when
programming, it is also easier to interpret simplified mnemonics when reading existing code.
Simplified mnemonics are not a formal part of the architecture, but rather a recommendation for
assemblers that support the instruction set.
Simplified mnemonics for VLE instructions provide a consistent assembly-language interface with the
PowerPC architecture. Many simplified mnemonics were originally defined in the PowerPC architecture
documentation. Some assemblers created their own, and others have been added to support extensions to
the instruction set (for example, AltiVec instructions and Book E auxiliary processing units (APUs)).
Simplified mnemonics for new architecturally defined and new implementation-specific special-purpose
registers (SPRs) are described here very generally.
A.2.2 Subtract
Subtract from instructions subtract the second operand (rA) from the third (rB). The simplified
mnemonics in Table A-2 use the more common order in which the third operand is subtracted from the
second.
Table A-2. Subtract Simplified Mnemonics
Extract and left justify word immediate e_extlwi rA,rS,n,b (n > 0) e_rlwinm rA,rS,b,0,n – 1
Extract and right justify word immediate e_extrwi rA,rS,n,b (n > 0) e_rlwinm rA,rS,b + n,32 – n,31
Insert from left word immediate e_inslwi rA,rS,n,b (n > 0) e_rlwimi rA,rS,32 – b,b,(b + n) – 1
Insert from right word immediate e_insrwi rA,rS,n,b (n > 0) e_rlwimi rA,rS,32 – (b + n),b,(b + n) – 1
Shift left word immediate e_slwi rA,rS,n (n < 32) e_rlwinm rA,rS,n,0,31 – n
Shift right word immediate e_srwi rA,rS,n (n < 32) e_rlwinm rA,rS,32 – n,n,31
Clear left word immediate e_clrlwi rA,rS,n (n < 32) e_rlwinm rA,rS,0,n,31
Clear right word immediate e_clrrwi rA,rS,n (n < 32) e_rlwinm rA,rS,0,0,31 – n
Clear left and shift left word immediate e_clrlslwi rA,rS,b,n (n ≤ b ≤ 31) e_rlwinm rA,rS,n,b – n,31 – n
The BO32, BI32, and BO16, BI16 operands correspond to fields in the instruction opcode, as Figure A-1
shows for Branch Conditional (e_bc, e_bcl, and se_bc) instructions.
e_bc (e_bcl)
0 5 6 9 10 11 12 15 16 30 31
se_bc
0 4 5 6 7 8 15
Both the BO32 and BO16 operands allow testing whether a CR bit causes a branch to occur based on a
true or false condition. The BO32 operand provides additional capability that allows branch operations that
involve decrementing the CTR and testing for a zero or non-zero CTR value.
The BI32 and BI16 operands identify a CR bit to test (whether a comparison is less than or greater than,
for example). The simplified mnemonics avoid the need to memorize the numerical values for BO32,
BI32, and BO16, BI16 operands.
For example, e_bc 2,0,target is a conditional branch that, as a BO32 value of 2 (0b10) indicates,
decrements the CTR, then branches if the decremented CTR is not zero. The operation specified by BO32
is abbreviated as d (for decrement) and nz (for not zero), which replace the c in the original mnemonic; so
the simplified mnemonic for e_bc becomes e_bdnz. The branch does not depend on a condition in the CR,
so BI32 can be eliminated, reducing the expression to e_bdnz target.
In addition to CTR operations, the BO32 operand provides branch decisions based on true or false
conditions. For example, if a branch instruction depends on an equal condition in CR0, the expression is
e_bc 1,2,target. To specify a true condition, the BO32 value becomes 1; the CR0 equal field is indicated
by a BI32 value of 2. Incorporating the branch-if-true condition a ‘t’ is used to replace the c in the original
mnemonic, e_bt. The BI32 value of 2 is replaced by the eq symbol. Using the simplified mnemonic and
the eq operand, the expression becomes e_bt eq,target.
This example tests CR0[EQ]; however, to test the equal condition in CR3 (CR bit 14), the expression
becomes e_bc 1,14,target. The BI32 operand of 14 indicates CR[14] (CR3[2], or BI32 field 0b1110). This
can be expressed as the simplified mnemonic, e_bt 4 × cr3 + eq,target.
The notation, 4 × cr3 + eq may at first seem awkward, but it eliminates computing the value of the CR bit.
It can be seen that (4 × 3) + 2 = 14. Note that although 32-bit registers in Book E processors are numbered
32–63, only values 0–15 are valid (or possible) for BI32 operands. A Book E–compliant processor
automatically translates the BI32 bit values; specifying a BI32 value of 14 selects bit 46 on a Book E
processor, or CR3[2] = CR3[EQ].
To reduce code size, VLE provides a 16-bit conditional branch instruction that uses the BO16 and BI16
operands. For example, the 32-bit conditional branch e_bc 1,2,target can be expressed using a 16-bit
instruction format, se_bc 1,2,target. In simplified mnemonic form this becomes se_bt eq,target. The BO16
operand only allows testing a true or false condition, unlike the BO32 operand that also allows
decrementing the CTR. The BI16 operand allows testing of only CR0, unlike the BI32 operand, which
allows testing CR0–CR3.
102 — 2 Decrement the CTR, then branch if the decremented CTR ≠ 0. dnz3
112 — 3 Decrement the CTR, then branch if the decremented CTR = 0. dz3
1
Instructions for which BO32 or BO16 are 0 (branch if condition true) or 1 (branch if condition false) do not depend on the CTR
value and alternately can be coded by incorporating the condition specified by the BI32 or BI16 fields. See Section A.5.2,
“Simplified Mnemonics that Incorporate CR Conditions (Eliminates BO32 and BO16 and Replaces BI32 with crS).”
2 Simplified mnemonics for branch instructions that do not test CR bits (BO32 = 2 or 3) should specify only a target. Otherwise
A.4.3 The BI32 and BI16 Operand—CR Bit and Field Representations
With standard branch mnemonics, the BI32 and BI16 operands are used to test a CR bit, as shown in the
example in Section A.4, “Branch Instruction Simplified Mnemonics,”
With simplified mnemonics, the BI32 and BI16 operands are handled differently depending on whether
the simplified mnemonic incorporates a CR condition to test, as follows:
• Some branch simplified mnemonics incorporate only the BO32 or BO16 operand. These simplified
mnemonics can use the architecturally defined BI32 or BI16 operand to specify the CR bit, as
follows:
— The BI32 or BI16 operands can be presented exactly as it is with standard mnemonics—as a
decimal number, 0–15 for the BI32 operand, and 0–3 for the BI16 operand.
— Symbols can be used to replace the decimal operand, as shown in the example in Section A.4,
“Branch Instruction Simplified Mnemonics,” where e_bt 4 * cr3 + eq,target could be used
instead of e_bt 14,target. This is described in Section A.4.4.1, “Specifying a CR Bit.”
The simplified mnemonics in Section A.5, “Simplified Mnemonics that Incorporate the BO32 and
BO16 Operands,” use one of these two methods to specify a CR bit.
• Additional simplified mnemonics incorporate CR conditions that would otherwise be specified by
the BI32 or BI16 operand, so the BI32 or BI16 operand is replaced by the crS operand to specify
the CR field. See Section A.4.4, “BI32 and BI16 Operand Instruction Encoding.”
These mnemonics are described in Section A.5.2, “Simplified Mnemonics that Incorporate CR Conditions
(Eliminates BO32 and BO16 and Replaces BI32 with crS).”
0 1
Standard branch mnemonics and The BI32 operand specifies the entire 4-bit field and the BI16
simplified mnemonics based on CTR values operand specifies a 2-bit field. If CR0 is used, the bit can be
identified by LT, GT, EQ, or SO. For BI32, if CR1–CR3 are used,
the form 4 * crS + LT|GT|EQ|SO can be used.
Integer record-form instructions update CR0 and floating-point record-form instructions update CR1, as
described in Table A-6.
CR0[1] 1 33 00 01 01 Positive (GT)—Set when the result is positive (and not zero).
Some simplified mnemonics incorporate only the BO32 or BO16 fields (as described Section A.4.2,
“Eliminating the BO32 and BO16 Operands”). If one of these simplified mnemonics is used and the CR
must be accessed, the BI32 or BI16 operand can be specified either as a numeric value or by using the
symbols in Table A-7.
Compare word instructions (described in Section A.6, “Compare Word Simplified Mnemonics”),
floating-point compare instructions, move to CR instructions, and others can also modify CR fields, so
CR0 and CR1 may hold values that do not adhere to the meanings described in Table A-6.
Table A-7. BI32 and BI16 Operand Settings for CR Fields for Branch Comparisons
CRn[0] 4 * cr0 + lt (or lt) 0 32 00 00 00 Less than or floating-point less than (LT, FL).
4 * cr1 + lt 4 36 01 — For integer compare instructions:
4 * cr2 + lt 8 40 10 — rA < SIMM or rB (signed comparison) or rA <
4 * cr3+ lt 12 44 11 — UIMM or rB (unsigned comparison).
For floating-point compare instructions: frA < frB.
CRn[1] 4 * cr0 + gt (or gt) 1 33 00 01 01 Greater than or floating-point greater than (GT,
4 * cr1 + gt 5 37 01 — FG).
4 * cr2 + gt 9 41 10 — For integer compare instructions:
4 * cr3+ gt 13 45 11 — rA > SIMM or rB (signed comparison) or rA >
UIMM or rB (unsigned comparison).
For floating-point compare instructions: frA > frB.
Table A-7. BI32 and BI16 Operand Settings for CR Fields for Branch Comparisons (continued)
Only the most useful simplified mnemonics are found in Section A.5, “Simplified Mnemonics that
Incorporate the BO32 and BO16 Operands.” Unusual cases can still be coded using a standard branch
conditional syntax.
cr1 01 — 36–39
cr2 10 — 40–43
cr3 11 — 44–47
To identify a CR bit, an expression in which a CR field symbol is multiplied by 4 and then added to a
bit-number-within-CR-field symbol can be used, (for example, cr0 * 4 + eq).
Table A-10 shows the syntax for basic simplified branch mnemonics
Table A-10. Branch Instructions
Standard Simplified
Instruction Syntax Syntax
Mnemonic Mnemonic
Branch e_b (e_bl) target_addr N/A, syntax does not include BO32 or BO16
se_b (se_bl)
Branch to Count Register se_bctr (se_bctrl) — N/A, syntax does not include BO32 or BO16
1 x stands for one of the symbols in Table A-5, where applicable.
2 BI32 or BI16 can be a numeric value or an expression as shown in Table A-8.
The simplified mnemonics in Table A-9 that test a condition require a corresponding CR bit as the first
operand (as the examples 2–5 in Section A.5.1, “Examples that Eliminate the BO32 and BO16 Operands,”
below illustrate). The symbols in Table A-8 can be used in place of a numeric value.
Simplified Simplified
Branch Semantics e_bc se_bc
Mnemonic Mnemonic
Branch if condition true e_bc 1,BI32,target e_bt BI32,target1 se_bc 1,BI16,target se_bt BI16,target
Branch if condition false e_bc 0,BI32,target e_bf BI32,target1 se_bc 0,BI16,target se_bf BI16,target
Simplified
Branch Semantics e_bcl
Mnemonic
lt Less than — LT
eq Equal — EQ
gt Greater than — GT
ne Not equal — EQ
so Summary overflow — SO
Table A-14 shows the syntax for simplified branch mnemonics that incorporate CR conditions. Here, crS
replaces a BI32 operand to specify only a CR field (because the specific CR bit within the field is now part
of the simplified mnemonic. Note that the default is CR0; if no crS is specified, CR0 is used.
Table A-14. Branch Instructions and Simplified Mnemonics that Incorporate CR Conditions
Standard Simplified
Instruction Syntax Syntax
Mnemonic Mnemonic
Instructions using the mnemonics in Table A-15 indicate the condition bit, but not the CR field. If no field
is specified, CR0 is used. For 32-bit instruction forms (denoted with the e_ prefix) the CR field symbols
defined in Table A-8 (cr0–cr3) are used, as shown in examples 2–3 of Section A.5.3, “Branch Simplified
Mnemonics that Incorporate CR Conditions: Examples,” below. Note that the 16-bit instruction forms
(denoted with the se_ prefix) must use CR0.
Simplified Simplified
Branch Semantics e_bc se_bc
Mnemonic Mnemonic
Branch if less than e_bc 1,BI321,target e_blt crS,target se_bc 1,BI161,target se_blt target
Branch if less than or equal e_bc 0,BI322,target e_ble crS,target se_bc 0,BI162,target se_ble target
Branch if equal e_bc 1,BI323,target e_beq crS,target se_bc 1,BI163,target se_beq target
Branch if greater than or equal e_bc 0,BI321,target e_bge crS,target se_bc 0,BI161,target se_bge target
Branch if greater than e_bc 1,BI322,target e_bgt crS,target se_bc 1,BI162,target se_bgt target
Branch if not equal e_bc 0,BI323,target e_bne crS,target se_bc 0,BI163,target se_bne target
Branch if summary overflow e_bc 1,BI324,target e_bso crS,target se_bc 1,BI164,target se_bso target
Branch if not summary overflow e_bc 0,BI324,target e_bns crS,target se_bc 0,BI164,target se_bns target
Table A-17 shows simplified branch mnemonics and syntax for e_bcl.
Table A-17. Simplified Mnemonics for e_bcl with Comparison Conditions and LR Updating
As with branch mnemonics, the crD field of a compare instruction can be omitted if CR0 is used, as shown
in examples 1 and 3 below. Otherwise, the target CR field must be specified as the first operand. The
following examples use word compare mnemonics:
1. Compare rA with immediate value 100 as signed 32-bit integers and place result in CR0.
e_cmpwi rA,100 equivalent to e_cmp16i rA,100
2. Same as (1), but place results in CR4.
e_cmpwi cr3,rA,100 equivalent to e_cmpi 3,rA,100
3. Compare rA and rB as unsigned 32-bit integers and place result in CR0.
cmplw rA,rB equivalent to cmpl 0,0,rA,rB
lt Less than 16 1 0 0 0 0
eq Equal 4 0 0 1 0 0
gt Greater than 8 0 1 0 0 0
ne Not equal 24 1 1 0 0 0
— Unconditional 31 1 1 1 1 1
1
The symbol ‘<U’ indicates an unsigned less-than evaluation is performed.
2 The symbol ‘>U’ indicates an unsigned greater-than evaluation is performed.
The mnemonics in Table A-20 are variations of trap instructions, with the most useful TO values
represented in the mnemonic rather than specified as a numeric operand.
The following examples use the trap mnemonics shown in Table A-20:
1. Trap if rA is not equal to rB.
twne rA,rB equivalent to tw 24,rA,rB
2. Trap unconditionally.
trap equivalent to tw 31,0,0
Trap instructions evaluate a trap condition by comparing the contents of rA with the contents of rB. The
comparison results in five conditions that are ANDed with operand TO. If the result is not 0, the trap
exception handler is invoked. See Table A-21 for these conditions.
Table A-21. TO Operand Bit Encoding
2 Equal
SPRGs mtsprg n,rS mtspr 272 + n,rS mfsprg rD,n mfspr rD,272 + n
mtsprgn,rS mfsprgn rD
e_bdnz target1 e_bc 2,0,target Decrement CTR, branch if CTR ≠ 0 (e_bc without LR
update)
e_bdnzl target 1 e_bcl 2,0,target Decrement CTR, branch if CTR ≠ 0 (e_bcl with LR
update)
e_bdz target 1 e_bc 3,0,target Decrement CTR, branch if CTR = 0 (e_bc without LR
update)
e_bdzl target 1 e_bcl 3,BI32,target Decrement CTR, branch if CTR = 0 (e_bcl with LR
update)
e_beql crS,target e_bcl 1,BI32 2,target Branch if equal (e_bcl with LR updating)
e_bf BI32,target e_bc 0,BI32,target Branch if condition false 3 (e_bc without LR update)
e_bfl BI32,target e_bcl 0,BI32,target Branch if condition false 3 (e_bcl with LR update)
e_bge crS,target e_bc 0,BI324,target Branch if greater than or equal (e_bc without LR
updating)
e_bgel crS,target e_bcl 0,BI324,target Branch if greater than or equal (e_bcl with LR updating)
e_bgt crS,target e_bc 1,BI325,target Branch if greater than (e_bc without LR updating)
e_ble crS,target e_bc 0,BI325,target Branch if less than or equal (e_bc without LR updating)
e_blel crS,target e_bcl 0,BI325,target Branch if less than or equal (e_bcl with LR updating)
e_blt crS,target e_bc 1,BI324,target Branch if less than (e_bc without LR updating)
e_bltl crS,target e_bcl 1,BI324,target Branch if less than (e_bcl with LR updating)
e_bne crS,target e_bc 0,BI323,target Branch if not equal (e_bc without LR updating)
e_bnel crS,target e_bcl 0,BI323,target Branch if not equal (e_bcl with LR updating)
e_bng crS,target e_bc 0,BI325,target Branch if not greater than (e_bc without LR updating)
e_bngl crS,target e_bcl 0,BI325,target Branch if not greater than (e_bcl with LR updating)
e_bnl crS,target e_bc 0,BI324,target Branch if not less than (e_bc without LR updating)
e_bnll crS,target e_bcl 0,BI324,target Branch if not less than (e_bcl with LR updating)
e_bns crS,target e_bc 0,BI326,target Branch if not summary overflow (e_bc without LR
updating)
e_bnsl crS,target e_bcl 0,BI326,target Branch if not summary overflow (e_bcl with LR updating)
e_bnu crS,target e_bc 0,BI326,target Branch if not unordered (e_bc without LR updating)
e_bnul crS,target e_bcl 0,BI326,target Branch if not unordered (e_bcl with LR updating)
e_bso crS,target e_bc 1,BI326,target Branch if summary overflow (e_bc without LR updating)
e_bsol crS,target e_bcl 1,BI326,target Branch if summary overflow (e_bcl with LR updating)
e_bt BI32,target e_bc 1,BI32,target Branch if condition true3 (e_bc without LR update)
e_btl BI32,target e_bcl 1,BI32,target Branch if condition true 3 (e_bcl with LR update)
e_clrlslwi rA,rS,b,n (n ≤ b ≤ e_rlwinm rA,rS,n,b – n,31 – n Clear left and shift left word immediate
31)
e_clrlwi rA,rS,n (n < 32) e_rlwinm rA,rS,0,n,31 Clear left word immediate
e_clrrwi rA,rS,n (n < 32) e_rlwinm rA,rS,0,0,31 – n Clear right word immediate
e_extlwi rA,rS,n,b (n > 0) e_rlwinm rA,rS,b,0,n – 1 Extract and left justify word immediate
e_extrwi rA,rS,n,b (n > 0) e_rlwinm rA,rS,b + n,32 – n,31 Extract and right justify word immediate
e_inslwi rA,rS,n,b (n > 0) e_rlwimi rA,rS,32 – b,b,(b + n) – 1 Insert from left word immediate
e_insrwi rA,rS,n,b (n > 0) e_rlwimi rA,rS,32 – (b + n),b,(b + n) Insert from right word immediate
–1
e_slwi rA,rS,n (n < 32) e_rlwinm rA,rS,n,0,31 – n Shift left word immediate
e_srwi rA,rS,n (n < 32) e_rlwinm rA,rS,32 – n,n,31 Shift right word immediate
sub rD,rA,rB subf rD,rB,rA Subtract from
Rev. Editor/
Date Substantive Change(s)
Number Writer
E Effective address (EA). The 32- or 64-bit address specified for a load, store, or an
instruction fetch. This address is then submitted to the MMU for
translation to either a physical memory address or an I/O address.
Exponent. In the binary representation of a floating-point number, the
exponent is the component that normally signifies the integer power
to which the value two is raised in determining the value of the
represented number. See also Biased exponent.
I IEEE 754. A standard written by the Institute of Electrical and Electronics Engineers that
defines operations and representations of binary floating-point arithmetic.
Inexact. Loss of accuracy in an arithmetic operation when the rounded result differs
from the infinitely precise value with unbounded range.
L Least-significant bit (lsb). The bit of least value in an address, register, data element, or
instruction encoding.
Little-endian. A byte-ordering method in memory where the address n of a word
corresponds to the least-significant byte. In an addressed memory word, the
bytes are ordered (left to right) 3, 2, 1, 0, with 3 being the most-significant
byte. See Big-endian.
O Overflow. An error condition that occurs during arithmetic operations when the result
cannot be stored accurately in the destination register(s). For example, if two
32-bit numbers are multiplied, the result may not be representable in 32 bits.
S Saturate. A value v which lies outside the range of numbers representable by a destination
type is replaced by the representable number closest to v.
Signaling NaN. A type of NaN that generates an invalid operation program
exception when it is specified as arithmetic operands. See Quiet NaN.
Significand. The component of a binary floating-point number that consists of an
explicit or implicit leading bit to the left of its implied binary point and a
fraction field to the right.
Sticky bit. A bit that when set must be cleared explicitly.
Supervisor mode. The privileged operation state of a processor. In supervisor mode,
software, typically the operating system, can access all control registers and
can access the supervisor memory space, among other privileged
operations.
T Tiny. A floating-point value that is too small to be represented for a particular precision
format, including denormalized numbers; they do not include ±0.
U Underflow. An error condition that occurs during arithmetic operations when the result
cannot be represented accurately in the destination register. For example,
underflow can happen if two floating-point fractions are multiplied and the result
requires a smaller exponent and/or mantissa than the single-precision format can
provide. In other words, the result is too small to be represented accurately.