Converts a floating-point operand to a 32-bit signed integer, rounding the result towards 0.
PowerPC | |
---|---|
fctiwz | FRT,FRB |
fctiwz. | FRT,FRB |
POWER2 | |
---|---|
fcirz | FRT,FRB |
fcirz. | FRT,FRB |
The fctiwz and fcirz instructions convert the floating-point operand in floating-point register (FPR) FRB to a 32-bit, signed, fixed-point integer, rounding the operand toward 0. The result is placed in bits 32-63 of FPR FRT. Bits 0-31 of FPR FRT are undefined.
If the operand in FPR FRB is greater than 231 - 1, then the bits 32-63 of FPR FRT are set to 0x7FFF FFFF. If the operand in FPR FRB is less than -231, then the bits 32-63 of FPR FRT are set to 0x8000 0000.
The fctiwz and fcirz instructions each have two syntax forms. Each syntax form has a different effect on Condition Register Field 1.
Syntax Form | Floating-Point Status and Control Register | Record Bit (Rc) | Condition Register Field 1 |
fctiwz | C,FL,FG,FE,FU,FR,FI,FX,XX,VXCVI, VXSNAN | 0 | None |
fctiwz. | C,FL,FG,FE,FU,FR,FI,FX,XX,VXCVI, VXSNAN | 1 | FX,FEX,VX,OX |
fcirz | C,FL,FG,FE,FU,FR,FI,FX,XX,VXCVI, VXSNAN | 0 | None |
fcirz. | C,FL,FG,FE,FU,FR,FI,FX,XX,VXCVI, VXSNAN | 1 | FX,FEX,VX,OX |
The syntax forms of the fctiwz and fcirz instructions always affect the Floating-Point Status and Control Register. If the syntax form sets the Record (Rc) bit to 1, the instruction affects the Floating-Point Exception (FX), Floating-Point Enabled Exception (FEX), Floating-Point Invalid Operation Exception (VX), and Floating-Point Overflow Exception (OX) bits in Condition Register Field 1. FPSCR(C,FI,FG,FE,FU) are undefined.
FRT | Specifies the floating-point register where the integer result is placed. |
FRB | Specifies the source floating-point register for the floating-point operand. |
The following code adds a floating-point value to an array element selected based on a second floating-point value. If value2 is greater than or equal to n, but less than n+1, add value1 to the nth element of the array:
# Assume GPR 4 contains the address of the first element of # the array. # Assume GPR 1 contains the stack pointer. # Assume a doubleword TEMP variable is allocated on the stack # for use by the conversion routine. # Assume FPR 6 contains value2. # Assume FPR 4 contains value1. fctiwz 5,6 # Convert value2 to integer. stfd 5,TEMP(1) # Store to temp location. lwz 3,TEMP+4(1) # Get the integer part of the # doubleword. lfdx 5,3,4 # Get the selected array element. fadd 5,5,4 # Add value1 to array element. stfd 5,3,4 # Save the new value of the # array element.
Floating-Point Arithmetic Instructions .
Interpreting the Contents of a Floating-Point Register .