All MAL floating point instructions are performed on floating point register operands only. Single precision operands use even-numbered registers only. Double precision floating point operands use even-numbered registers paired with the following odd-numbered register. The double precision register pair is referenced using the even-numbered register.
Floating numbers are moved between floating point registers and RAM using the l.s and s.s instructions. For example:
l.s $f0, Address
loads a single precision floating point number from the contents of Address into register $f0. Note that $f0, unlike $0, has no special value and is typically used to return the values of floating point functions.
The instruction
s.s $f0, Address
moves the contents of the single precision floating register $f0 to location Address in RAM. In the floating point load/store instructions, Address is a base-displacement address which may use a general register for the base address. For example, if X is a .float array, the instructions:
la $4, X l.s $f2, 12($4)
will load the single precision floating point register $f2 with element X[3].
The li.s instruction is used to load a floating point register with a constant immediate operand. For example,
li.s $f2, 1.0
loads the floating point register $f2 with the single precision floating point value of 1.0. The constant specified in a li.s instruction must contain a decimal point.
The mov.s instruction moves the contents of one floating point register to another. For example:
mov.s $f0, $f2
moves the contents of register $f2 into $f0.
The single precision floating point arithmetic instructions are: add.s, sub.s, mul.s, and div.s. The operands for all floating point arithmetic instructions are floating point registers. For example:
add.s $f4, $f2, $f0
performs single precision floating addition on the contents of registers $f2 and $f0 and the result is placed in $f4.
The cvt.s.w and cvt.w.s instructions are used to convert between integer and floating point representations. For example:
cvt.s.w $f4, $f2
converts the contents of register $f2 from 2's complement integer representation to single precision floating point number in $f4. The instruction:
cvt.w.s $f4, $f2
converts the contents of register $f2 from single precision floating point representation to a 2's complement integer in $f4.
Double precision operations can be specified for all of the preceding instructions by replacing the `.s' suffix with `.d'. It is an error to specify general registers for any of these operations, except as a base-displacement Address in the load/store instructions.
A pair of special move instructions are used to move data between general and floating point registers. The floating point registers are implemented in co-processor 1. The mfc1 (move from co-processor 1) instruction is used to move the contents of a floating point register to a general register. For example,
mfc1 $4, $f2
moves the contents of floating point register $f2 to general register $4 and
mtc1 $4, $f2
moves the contents of general register $4 to floating point register $f2. As in all move operations, no data type conversion is performed.
The complete list of MAL floating point instructions is shown below:
Notes: