Converts a floating-point operand to a 32-bit signed integer.
Bits | Value |
---|---|
0-5 | 63 |
6-10 | FRT |
11-15 | /// |
16-20 | FRB |
21-30 | 14 |
31 | Rc |
PowerPC | |
---|---|
fctiw | FRT, FRB |
fctiw. | FRT, FRB |
POWER2 | |
---|---|
fcir | FRT, FRB |
fcir. | FRT, FRB |
The fctiw and fcir instructions convert the floating-point operand in floating-point register (FPR) FRB to a 32-bit signed, fixed-point integer, using the rounding mode specified by Floating-Point Status and Control Register (FPSCR) RN. 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 fctiw and fcir instruction 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 |
fctiw | C,FL,FG,FE,FU,FR,FI,FX,XX,VXCVI, VXSNAN | 0 | None |
fctiw. | C,FL,FG,FE,FU,FR,FI,FX,XX,VXCVI, VXSNAN | 1 | FX,FEX,VX,OX |
fcir | C,FL,FG,FE,FU,FR,FI,FX,XX,VXCVI, VXSNAN | 0 | None |
fcir. | C,FL,FG,FE,FU,FR,FI,FX,XX,VXCVI, VXSNAN | 1 | FX,FEX,VX,OX |
The syntax forms of the fctiw and fcir instructions always affect the FPSCR. 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 converts a floating-point value into an integer for use as an index in an array of floating-point values:
# 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 the floating-point value for conversion # into an index. fctiw 5,6 # Convert floating-point value # to integer. stfd 5,TEMP(1) # Store to temp location. lwz 3,TEMP+4(1) # Get the integer part of the # doubleword. lfd 5,0(3) # Get the selected array element. # FPR 5 now contains the selected array element.
Floating-Point Arithmetic Instructions .
Interpreting the Contents of a Floating-Point Register .