lfsux
Load Floating-Point Single with Update Indexed - 7C 00 04 6E
lfsux

Instruction Syntax

Mnemonic Format Flags
lfsux frD,rA,rB -

Instruction Encoding

0
1
1
1
1
1
D
D
D
D
D
A
A
A
A
A
B
B
B
B
B
1
0
0
0
1
1
0
1
1
1
/

Field Bits Description
Primary Opcode 0-5 011111 (0x1F)
frD 6-10 Destination floating-point register
rA 11-15 Source register A
rB 16-20 Source register B
XO 21-30 567 (Extended opcode)
Rc 31 Reserved (0)

Operation

EA ← (rA) + (rB)
frD ← DOUBLE(MEM(EA, 4))
rA ← EA

A single-precision floating-point value (32 bits) is loaded from memory, converted to double-precision format, and placed in floating-point register frD. The effective address is computed by adding the contents of registers rA and rB. After the load, the effective address is stored back into register rA.

Note: This instruction cannot be used with rA=0. The update form requires a valid base register. The loaded single-precision value is automatically converted to double-precision before being stored in the FPR. This indexed update form is particularly useful for traversing single-precision floating-point data structures with dynamic stride patterns while maintaining automatic pointer advancement.

Affected Registers

rA - Updated with the effective address after the load operation.

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

Examples

Audio DSP - Variable Rate Resampling

# Resample audio with time-varying sample rate
lis r3, input_audio@ha
addi r3, r3, input_audio@l
lis r4, rate_control@ha
addi r4, r4, rate_control@l
lwz r5, num_output_samples(r0)
li r6, 0                    # Input position (fixed-point)

resample_loop:
    # Load rate control value (determines advance)
    lwz r7, 0(r4)           # Load rate multiplier
    lfsux f1, r3, r7        # Load audio sample and advance by rate
    
    # Apply anti-aliasing filter
    bl apply_antialiasing   # Process sample in f1
    
    # Store resampled output
    bl store_output_sample
    
    addi r4, r4, 4          # Next rate control value
    subi r5, r5, 1          # Decrement output counter
    cmpwi r5, 0
    bne resample_loop       # Continue resampling

Scientific Computing - Sparse Matrix Operations

# Process sparse matrix with compressed storage
lis r3, sparse_values@ha
addi r3, r3, sparse_values@l
lis r4, offset_array@ha
addi r4, r4, offset_array@l
lwz r5, num_nonzero(r0)     # Number of non-zero elements

sparse_matrix_loop:
    lwz r6, 0(r4)           # Load offset to next element
    lfsux f1, r3, r6        # Load sparse value and advance by offset
    
    # Apply matrix operation (e.g., scaling, transformation)
    lfs f2, scale_factor(r0)
    fmul f3, f1, f2         # Scale the sparse element
    
    # Store processed value back
    stfs f3, 0(r3)          # Store back to current position
    
    addi r4, r4, 4          # Next offset
    subi r5, r5, 1          # Decrement element counter
    cmpwi r5, 0
    bne sparse_matrix_loop  # Continue processing

Game Engine - Particle System

# Update particle system with variable time steps
lis r3, particle_array@ha
addi r3, r3, particle_array@l
lis r4, timestep_array@ha
addi r4, r4, timestep_array@l
lwz r5, num_particles(r0)   # Number of active particles

particle_update_loop:
    # Load variable timestep for this particle
    lwz r6, 0(r4)           # Load timestep offset
    
    # Load particle velocity
    lfsux f1, r3, r6        # Load velocity_x and advance
    lwz r7, 4               # Standard advance for next component
    lfsux f2, r3, r7        # Load velocity_y and advance
    lfsux f3, r3, r7        # Load velocity_z and advance
    
    # Load particle position (will be updated)
    lfsux f4, r3, r7        # Load position_x and advance
    lfsux f5, r3, r7        # Load position_y and advance
    lfsux f6, r3, r7        # Load position_z and advance
    
    # Load time delta for this particle
    lfsux f7, r3, r7        # Load time_delta and advance
    
    # Update position: position += velocity * time_delta
    fmadd f8, f1, f7, f4    # new_x = old_x + velocity_x * delta_t
    fmadd f9, f2, f7, f5    # new_y = old_y + velocity_y * delta_t
    fmadd f10, f3, f7, f6   # new_z = old_z + velocity_z * delta_t
    
    # Store updated position (move pointer back to overwrite)
    stfs f8, -12(r3)        # Store new position_x
    stfs f9, -8(r3)         # Store new position_y
    stfs f10, -4(r3)        # Store new position_z
    
    addi r4, r4, 4          # Next timestep
    subi r5, r5, 1          # Decrement particle counter
    cmpwi r5, 0
    bne particle_update_loop # Continue updating particles

Neural Network - Variable Architecture

# Process neural network with variable layer sizes
lis r3, weight_matrix@ha
addi r3, r3, weight_matrix@l
lis r4, layer_sizes@ha
addi r4, r4, layer_sizes@l
lis r5, input_vector@ha
addi r5, r5, input_vector@l
lwz r6, num_layers(r0)      # Number of layers

neural_layer_loop:
    lwz r7, 0(r4)           # Load current layer size
    lwz r8, 4(r4)           # Load next layer size
    
    # Calculate weight stride for this layer transition
    slwi r9, r8, 2          # next_layer_size * 4 (bytes per float)
    
    mr r10, r7              # Input neuron counter
    li r11, 0               # Output neuron index

output_neuron_loop:
    lfs f10, zero_constant(r0) # Initialize accumulator
    mr r12, r10             # Reset input counter
    mr r13, r5              # Reset input pointer

input_neuron_loop:
    lfs f1, 0(r13)          # Load input activation
    lfsux f2, r3, r9        # Load weight and advance by stride
    
    # Multiply-accumulate
    fmadd f10, f1, f2, f10  # sum += input * weight
    
    addi r13, r13, 4        # Next input
    subi r12, r12, 1        # Decrement input counter
    cmpwi r12, 0
    bne input_neuron_loop   # Continue inputs
    
    # Apply activation function (e.g., sigmoid)
    bl apply_activation     # Process activation in f10
    
    # Store output activation
    lis r14, output_vector@ha
    addi r14, r14, output_vector@l
    slwi r15, r11, 2        # Convert output index to byte offset
    stfsx f10, r14, r15     # Store activation
    
    addi r11, r11, 1        # Next output neuron
    cmpw r11, r8            # Check if done with layer
    blt output_neuron_loop  # Continue layer
    
    # Move to next layer
    addi r4, r4, 4          # Next layer size
    subi r6, r6, 1          # Decrement layer counter
    cmpwi r6, 0
    bne neural_layer_loop   # Continue layers

Image Processing - Adaptive Filtering

# Apply adaptive filter based on local image properties
lis r3, image_data@ha
addi r3, r3, image_data@l
lis r4, filter_offsets@ha
addi r4, r4, filter_offsets@l
lwz r5, image_width(r0)     # Image width
lwz r6, image_height(r0)    # Image height

adaptive_filter_loop:
    # Analyze local image properties to determine filter type
    bl analyze_local_properties # Returns filter type in r7
    
    # Calculate filter offset based on properties
    slwi r8, r7, 2          # Convert filter type to offset
    lwzx r9, r4, r8         # Load filter offset
    
    # Apply adaptive filter
    lfsux f1, r3, r9        # Load pixel and advance by filter-specific offset
    
    # Process based on filter type
    cmpwi r7, EDGE_FILTER
    beq apply_edge_filter
    cmpwi r7, SMOOTH_FILTER
    beq apply_smooth_filter
    cmpwi r7, SHARPEN_FILTER
    beq apply_sharpen_filter
    
apply_edge_filter:
    bl enhance_edges        # Apply edge enhancement
    b store_result
    
apply_smooth_filter:
    bl smooth_noise         # Apply noise reduction
    b store_result
    
apply_sharpen_filter:
    bl sharpen_details      # Apply detail enhancement

store_result:
    stfs f1, 0(r3)          # Store processed pixel
    
    # Continue to next pixel
    bl check_image_bounds   # Check if more pixels to process
    bne adaptive_filter_loop # Continue filtering

Financial Computing - Portfolio Optimization

# Optimize portfolio with dynamic weight adjustment
lis r3, asset_returns@ha
addi r3, r3, asset_returns@l
lis r4, weight_adjustments@ha
addi r4, r4, weight_adjustments@l
lis r5, portfolio_weights@ha
addi r5, r5, portfolio_weights@l
lwz r6, num_assets(r0)      # Number of assets in portfolio

portfolio_optimization_loop:
    # Load current weight adjustment
    lwz r7, 0(r4)           # Load adjustment offset
    
    # Load asset return with dynamic advancement
    lfsux f1, r3, r7        # Load return and advance by adjustment
    
    # Load current portfolio weight
    lfs f2, 0(r5)           # Load current weight
    
    # Calculate new weight based on return performance
    # new_weight = old_weight + return * adjustment_factor
    lfs f3, adjustment_factor(r0)
    fmadd f4, f1, f3, f2    # new_weight = old_weight + return * factor
    
    # Apply weight constraints (0 <= weight <= 1)
    lfs f5, zero_constant(r0)
    lfs f6, one_constant(r0)
    fcmpu cr0, f4, f5       # Compare with 0
    bge check_upper_bound
    fmr f4, f5              # Clamp to 0

check_upper_bound:
    fcmpu cr0, f4, f6       # Compare with 1
    ble weight_ok
    fmr f4, f6              # Clamp to 1

weight_ok:
    # Store updated weight
    stfs f4, 0(r5)          # Store new weight
    
    # Calculate contribution to portfolio performance
    fmul f7, f1, f4         # return * weight
    lfs f8, portfolio_value(r0)
    fadd f9, f8, f7         # Add to portfolio value
    stfs f9, portfolio_value(r0)
    
    addi r4, r4, 4          # Next weight adjustment
    addi r5, r5, 4          # Next portfolio weight
    subi r6, r6, 1          # Decrement asset counter
    cmpwi r6, 0
    bne portfolio_optimization_loop # Continue optimization

Robotics - Sensor Fusion

# Fuse sensor data with variable sampling rates
lis r3, sensor_data@ha
addi r3, r3, sensor_data@l
lis r4, sample_intervals@ha
addi r4, r4, sample_intervals@l
lis r5, fusion_weights@ha
addi r5, r5, fusion_weights@l
lwz r6, num_sensors(r0)     # Number of sensors

sensor_fusion_loop:
    # Load sampling interval for this sensor
    lwz r7, 0(r4)           # Load interval offset
    
    # Load sensor reading with time-based advancement
    lfsux f1, r3, r7        # Load sensor value and advance by interval
    
    # Load fusion weight for this sensor
    lfs f2, 0(r5)           # Load weight
    
    # Apply sensor-specific calibration
    bl calibrate_sensor     # Apply calibration to f1
    
    # Weight the sensor contribution
    fmul f3, f1, f2         # weighted_value = sensor_value * weight
    
    # Add to fused estimate
    lfs f4, fused_estimate(r0)
    fadd f5, f4, f3         # Add weighted contribution
    stfs f5, fused_estimate(r0)
    
    # Update confidence based on sensor reliability
    lfs f6, sensor_confidence(r0)
    fmul f7, f2, f2         # weight²
    fadd f8, f6, f7         # Add to total confidence
    stfs f8, sensor_confidence(r0)
    
    addi r4, r4, 4          # Next sample interval
    addi r5, r5, 4          # Next fusion weight
    subi r6, r6, 1          # Decrement sensor counter
    cmpwi r6, 0
    bne sensor_fusion_loop  # Continue fusion

# Normalize fused estimate by total confidence
lfs f9, fused_estimate(r0)
lfs f10, sensor_confidence(r0)
fdiv f11, f9, f10           # normalized_estimate = sum / total_confidence
stfs f11, final_estimate(r0)

Related Instructions

lfs, lfsu, lfsx, stfsux, lfdux, lbzux

Back to Index