fmul
Floating Multiply - FC 00 00 32
fmul
Instruction Syntax
Mnemonic | Format | Flags |
fmul | frD,frA,frC | Rc = 0 |
fmul. | frD,frA,frC | Rc = 1 |
Instruction Encoding
1
1
1
1
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 | 111111 (0x3F) |
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 ← (frA) × (frC)
The contents of floating-point register frA are multiplied by the contents of floating-point register frC. The result is placed into floating-point register frD.
Note: Both operands and the result are in double-precision format. The multiplication follows IEEE-754 standard for floating-point arithmetic. Note that frB is not used in this instruction format.
Affected Registers
Condition Register (CR1 field)
(if Rc = 1)
- Reflects floating-point exception summary and status
Floating-Point Status and Control Register (FPSCR)
Affected fields:
- FPRF (Floating-Point Result Flags)
- FX (Floating-Point Exception Summary)
- OX (Overflow Exception)
- UX (Underflow Exception)
- XX (Inexact Exception)
- VXIMZ (Invalid Operation Exception for 0 × ∞)
- FR (Fraction Rounded)
- FI (Fraction Inexact)
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 Floating-Point Multiplication
lfd f1, factor_a(r0) # Load first operand lfd f2, factor_b(r0) # Load second operand fmul f3, f1, f2 # f3 = f1 × f2 stfd f3, result(r0) # Store result
Multiplication with Condition Recording
lfd f1, input1(r0) # Load first input lfd f2, input2(r0) # Load second input fmul. f3, f1, f2 # f3 = f1 × f2, set CR1 with FP status # CR1 now reflects floating-point exception status
Scaling Operation
# Scale a value by a constant factor lfd f1, input_value(r0) # Load input value lfd f2, scale_factor(r0) # Load scaling factor fmul f3, f1, f2 # f3 = input × scale stfd f3, scaled_result(r0) # Store scaled result
Vector Scaling
# Scale a 3D vector by a scalar lfd f1, vector_x(r0) # Load vector.x lfd f2, vector_y(r0) # Load vector.y lfd f3, vector_z(r0) # Load vector.z lfd f4, scale_factor(r0) # Load scalar fmul f5, f1, f4 # scaled.x = vector.x × scale fmul f6, f2, f4 # scaled.y = vector.y × scale fmul f7, f3, f4 # scaled.z = vector.z × scale
Area/Volume Calculations
# Calculate area of rectangle lfd f1, width(r0) # Load width lfd f2, height(r0) # Load height fmul f3, f1, f2 # area = width × height stfd f3, area(r0) # Store area
Matrix Element Multiplication
# Multiply corresponding matrix elements lfd f1, matrix1_element(r0) # Load element from matrix1 lfd f2, matrix2_element(r0) # Load element from matrix2 fmul f3, f1, f2 # result = element1 × element2 stfd f3, result_element(r0) # Store result element
Physics Calculations
# Calculate kinetic energy: KE = 0.5 × mass × velocity² lfd f1, mass(r0) # Load mass lfd f2, velocity(r0) # Load velocity lfd f3, half_constant(r0) # Load 0.5 fmul f4, f2, f2 # velocity² fmul f5, f1, f4 # mass × velocity² fmul f6, f3, f5 # 0.5 × mass × velocity² stfd f6, kinetic_energy(r0) # Store kinetic energy
Dot Product Component
# Calculate part of dot product lfd f1, vector1_x(r0) # Load v1.x lfd f2, vector1_y(r0) # Load v1.y lfd f3, vector1_z(r0) # Load v1.z lfd f4, vector2_x(r0) # Load v2.x lfd f5, vector2_y(r0) # Load v2.y lfd f6, vector2_z(r0) # Load v2.z fmul f7, f1, f4 # v1.x × v2.x fmul f8, f2, f5 # v1.y × v2.y fmul f9, f3, f6 # v1.z × v2.z fadd f10, f7, f8 # (v1.x × v2.x) + (v1.y × v2.y) fadd f11, f10, f9 # dot_product = sum of all products
Financial Calculations
# Calculate compound interest amount lfd f1, principal(r0) # Load principal amount lfd f2, interest_rate(r0) # Load interest rate (as decimal) lfd f3, time_periods(r0) # Load number of periods # Simple calculation: amount = principal × (1 + rate) × periods lfd f4, one_constant(r0) # Load 1.0 fadd f5, f4, f2 # 1 + rate fmul f6, f5, f3 # (1 + rate) × periods fmul f7, f1, f6 # principal × compound factor stfd f7, final_amount(r0) # Store result