fmuls
Floating Multiply Single - EC 00 00 32
fmuls

Instruction Syntax

Mnemonic Format Flags
fmuls frD,frA,frC Rc = 0
fmuls. frD,frA,frC Rc = 1

Instruction Encoding

1
1
1
0
1
1
D
D
D
D
D
A
A
A
A
A
0
0
0
0
0
C
C
C
C
C
0
0
0
1
1
0
0
1
Rc

Field Bits Description
Primary Opcode 0-5 111011 (0x3B)
frD 6-10 Destination floating-point register
frA 11-15 Source floating-point register A
Reserved 16-20 00000
frC 21-25 Source floating-point register C
XO 26-30 11001 (25)
Rc 31 Record Condition Register

Operation

frD ← SINGLE((frA) × (frC))

The contents of floating-point register frA are multiplied by the contents of floating-point register frC. The result is rounded to single-precision and placed into floating-point register frD.

Note: Both operands are converted to single-precision format before the operation, and the result is in single-precision format (stored in double-precision format in the FPR). The multiplication follows IEEE-754 standard for single-precision floating-point arithmetic. Note that frB is not used in this instruction format.

Affected Registers

Condition Register (CR1 field)

(if Rc = 1)

Floating-Point Status and Control Register (FPSCR)

Affected fields:

For more information on floating-point status see Section 2.1.4, "Floating-Point Status and Control Register (FPSCR)," in the PowerPC Microprocessor Family: The Programming Environments manual.

Examples

Basic Single-Precision Multiplication

lfs f1, factor_a(r0)       # Load first factor (single-precision)
lfs f2, factor_b(r0)       # Load second factor (single-precision)
fmuls f3, f1, f2           # f3 = f1 × f2 (single-precision)
stfs f3, result(r0)        # Store single-precision result

Single-Precision with Condition Recording

lfs f1, input1(r0)         # Load first input
lfs f2, input2(r0)         # Load second input
fmuls. f3, f1, f2          # f3 = f1 × f2, set CR1 with FP status
# CR1 now reflects floating-point exception status

Graphics/Game Vector Scaling

# Scale a 3D vector by a scalar (single-precision for speed)
lfs f1, vector_x(r0)       # Load vector.x (single)
lfs f2, vector_y(r0)       # Load vector.y (single)
lfs f3, vector_z(r0)       # Load vector.z (single)
lfs f4, scale_factor(r0)   # Load scalar (single)
fmuls f5, f1, f4           # scaled.x = vector.x × scale
fmuls f6, f2, f4           # scaled.y = vector.y × scale
fmuls f7, f3, f4           # scaled.z = vector.z × scale

Audio Processing

# Apply gain to audio sample
lfs f1, audio_sample(r0)   # Load audio sample
lfs f2, gain_factor(r0)    # Load gain factor
fmuls f3, f1, f2           # amplified = sample × gain
stfs f3, output_sample(r0) # Store amplified sample

Graphics Color Scaling

# Scale color channels by brightness factor
lfs f1, color_red(r0)      # Load red channel
lfs f2, color_green(r0)    # Load green channel
lfs f3, color_blue(r0)     # Load blue channel
lfs f4, brightness(r0)     # Load brightness factor
fmuls f5, f1, f4           # scaled_red = red × brightness
fmuls f6, f2, f4           # scaled_green = green × brightness
fmuls f7, f3, f4           # scaled_blue = blue × brightness

Physics Calculations

# Calculate area of rectangle (single-precision for games)
lfs f1, width(r0)          # Load width
lfs f2, height(r0)         # Load height
fmuls f3, f1, f2           # area = width × height
stfs f3, area(r0)          # Store area

Animation/Interpolation

# Calculate interpolated position
lfs f1, start_position(r0) # Load start position
lfs f2, interpolation_t(r0) # Load interpolation factor (0.0-1.0)
lfs f3, distance(r0)       # Load total distance
fmuls f4, f2, f3           # offset = t × distance
fadds f5, f1, f4           # current_pos = start + offset
stfs f5, current_pos(r0)   # Store current position

Game Performance Optimization

# Matrix element multiplication (single-precision for speed)
lfs f1, matrix1_element(r0) # Load element from matrix1
lfs f2, matrix2_element(r0) # Load element from matrix2
fmuls f3, f1, f2            # result = element1 × element2
stfs f3, result_element(r0) # Store result element

Real-Time Collision Detection

# Calculate squared distance for collision (avoids sqrt)
lfs f1, delta_x(r0)        # Load X difference
lfs f2, delta_y(r0)        # Load Y difference
lfs f3, delta_z(r0)        # Load Z difference
fmuls f4, f1, f1           # dx²
fmuls f5, f2, f2           # dy²
fmuls f6, f3, f3           # dz²
fadds f7, f4, f5           # dx² + dy²
fadds f8, f7, f6           # distance² = dx² + dy² + dz²
stfs f8, dist_squared(r0)  # Store squared distance

Financial Calculations

# Calculate simple interest amount (single-precision)
lfs f1, principal(r0)      # Load principal amount
lfs f2, interest_rate(r0)  # Load interest rate
fmuls f3, f1, f2           # interest = principal × rate
stfs f3, interest_amount(r0) # Store interest amount

Related Instructions

fmul, fadds, fsubs, fdivs, fmadds

Back to Index