STREAMS 2
TYPE DOUBLE
FLOPS 2
BYTES 16

li r10, 6           # sixteen (4x4) elements per loop iteration
divd r10, r3, r10   # r3 holds loop limit, divide by elements per loop iteration
mtctr r10           # move to count register

# set accumulation registers to zero
fsub     0, 0, 0
fsub     1, 1, 1
fsub     2, 2, 2
fsub     3, 3, 3
fsub     4, 4, 4
fsub     5, 5, 5

# set c registers to zero
fsub     6, 6, 6
fsub     7, 7, 7
fsub     8, 8, 8
fsub     9, 9, 9
fsub     10, 10, 10
fsub     11, 11, 11

LOOP 6
# load A[i]
lfd      12, 0(STR0)
lfd      13, 8(STR0)
lfd      14, 16(STR0)
lfd      15, 24(STR0)
lfd      16, 32(STR0)
lfd      17, 40(STR0)

# load B[i]
lfd      18, 0(STR1)
lfd      19, 8(STR1)
lfd      20, 16(STR1)
lfd      21, 24(STR1)
lfd      22, 32(STR1)
lfd      23, 40(STR1)

# y = A[i]*B[i]-c
# fmsub FRT,FRA,FRC,FRB --> FRT <- [(FRA)×(FRC)] - (FRB)
fmsub   6, 12, 18, 6
fmsub   7, 13, 19, 7
fmsub   8, 14, 20, 8
fmsub   9, 15, 21, 9
fmsub   10, 16, 22, 10
fmsub   11, 17, 23, 11

# t = sum + y
fadd     24, 0, 6
fadd     25, 1, 7
fadd     26, 2, 8
fadd     27, 3, 9
fadd     28, 4, 10 
fadd     29, 5, 11

# tmp = t - sum; we can writewrite registers holding 'sum'
fsub     0, 24, 0
fsub     1, 25, 1
fsub     2, 26, 2
fsub     3, 27, 3
fsub     4, 28, 4
fsub     5, 29, 5

# c = tmp - y = (t - sum) - y; we can overwrite register holding 'y'
fsub     6, 0, 6
fsub     7, 1, 7
fsub     8, 2, 8
fsub     9, 3, 9
fsub     10, 4, 10
fsub     11, 5, 11 

# sum = t
fmr     0, 24
fmr     1, 25
fmr     2, 26
fmr     3, 27
fmr     4, 28
fmr     5, 29

addi STR0, STR0, 48
addi STR1, STR1, 48
