In MIPS the floating point hardware is referred to as "Coprocessor 1". Coprocessor 1 contains the floating point registers and floating point instructions.
There are 32 registers, $f0 through $f31, which are 32 bits each. They can be used as 32 float registers (32 bits each) or 16 double registers (64 bits each). All instructions that use double registers require even numbered registers.
The register usage convention is as follows:
Register Number |
Conventional Use |
---|---|
$f0 - $f3 | return values from functions |
$f4 - $f11 | temporary (saved by caller if necessary, called function can use without saving; not preserved across function calls |
$f12 - $f15 | value(s) passed to a function |
$f16 - $f19 | temporary (saved by caller if necessary, called function can use without saving; not preserved across function calls |
$f20 - $f31 | saved (called function must save and restore before exiting; preserved across function calls |
There are no mneumonic names for floating point registers.
Service | Code in $v0 | Arguments | Result |
---|---|---|---|
print float | 2 | $f12 = float to print | |
print double | 3 | $f12 = double to print | |
read float | 6 | $f0 contains float read | |
read double | 7 | $f0 contains double read |
You can find a complete list of instructions in Appendix F of the MIPS book.
Instruction | Syntax | Explanation |
---|---|---|
add double | add.d Fd, Fs, Ft | Fd = Fs + Ft all registers must be even numbered |
add single | add.s Fd, Fs, Ft | Fd = Fs + Ft |
sub double | sub.d Fd, Fs, Ft | Fd = Fs - Ft all registers must be even numbered |
sub single | sub.s Fd, Fs, Ft | Fd = Fs - Ft |
mult double | mul.d Fd, Fs, Ft | Fd = Fs * Ft all registers must be even numbered |
mult single | mul.s Fd, Fs, Ft | Fd = Fs * Ft |
divide double | div.d Fd, Fs, Ft | Fd = Fs / Ft this performs a floating point divide which may have a fractional part all registers must be even numbered |
divide single | div.s Fd, Fs, Ft | Fd = Fs / Ft this performs a floating point divide which may have a fractional part |
move double | mov.d Fd, Fs | Fd = Fs all registers must be even numbered |
move single | mov.s Fd, Fs | Fd = Fs |
load double | l.d Fd, offset(Rs) | load double value from memory into Fd Fd must be even numbered |
load single | l.s Fd, offset(Rs) | load single value from memory into Fd |
store double | s.d Fd, offset(Rs) | store double value in Fd into memory Fd must be even numbered |
store single | s.s Fd, offset(Rs) | store single value in Fd into memory |
compare and set if equal double | c.eq.d Fs, Ft | compare Fs and Ft, set flag to true if Fs == Ft Fs and Ft must be even numbered |
compare and set if equal single | c.eq.s Fs, Ft | compare Fs and Ft, set flag to true if Fs == Ft |
compare and set if less than or equal double | c.le.d Fs, Ft | compare Fs and Ft, set flag to true if Fs <= Ft Fs and Ft must be even numbered |
compare and set if less than or equal single | c.le.s Fs, Ft | compare Fs and Ft, set flag to true if Fs <= Ft |
compare and set if less than double | c.lt.d Fs, Ft | compare Fs and Ft, set flag to true if Fs < Ft Fs and Ft must be even numbered |
compare and set if less than single | c.lt.s Fs, Ft | compare Fs and Ft, set flag to true if Fs < Ft |
branch if status flag is true | bc1t label | branch to label if status flag is true |
branch if status flag is false | bc1f label | branch to label if status flag is false |
convert from single to double | cvt.d.s Fd,Fs | set Fd to double precision equivalent of single precision value in Fs |
convert from word (int) to double | cvt.d.w Fd,Fs | set Fd to double precision equivalent of integer value in Fs |
convert from double to single | cvt.s.d Fd,Fs | set Fd to double precision equivalent of single precision value in Fs |
convert from word (int) to single | cvt.s.w Fd,Fs | set Fd to single precision equivalent of integer value in Fs |
convert from double to word (int) | cvt.w.d Fd,Fs | set Fd to word (int) equivalent of double precision value in Fs |
convert from single to word (int) | cvt.w.s Fd,Fs | set Fd to word (int) equivalent of single precision value in Fs |
move from coprocessor 1 (Floating Point Unit) | mfc1 Rd,Fs | set Rd (int register) to value in Fs (floating point register) |
move to coprocessor 1 (Floating Point Unit) | mtc1 Rs,Fd | set Fd (floating point register) to value in Rs (int register) |
absolute value double | abs.d Fd, Fs | Fd = | Fs | all registers must be even numbered |
absolute value single | abs.s Fd, Fs | Fd = | Fs | |
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2019