Floating point constants
is the part of the code that evaluates
x is in
# Register Use Chart # $f0 -- x # $f2 -- sum of terms . . . . . # evaluate the quadratic l.s $f2,a # sum = a mul.s $f2,$f2,$f0 # sum = ax l.s $f4,bb # get b add.s $f2,$f2,$f4 # sum = ax + b mul.s $f2,$f2,$f0 # sum = (ax+b)x = ax^2 + bx l.s $f4,c # get c add.s $f2,$f2,$f4 # sum = ax^2 + bx + c . . . . . . .data a: .float 1.0 bb: .float 1.0 c: .float 1.0
The assembler objects to the symbolic address "b" (because there is a mnemonic "b", for branch) so use "bb" instead.
The polynomial is evaluated from left to right.
ax + b is calculated.
Then that is multiplied by
c is added in, giving
axx + bx + c.
x2 is not
This way of calculating a polynomial is called
It is useful to have in your bag of tricks.
Why (do you suppose) are the constants