0% found this document useful (0 votes)
8 views4 pages

MIPS Floating Point Instructions Guide

The document provides an overview of MIPS floating point instructions, highlighting the need for floating point representation for very small or large numbers and the limitations in precision. It details the single and double precision formats, arithmetic and data movement instructions, and the process for conditional jumps in floating point operations. The document emphasizes the use of the IEEE 754 standard and MIPS-specific instructions for handling floating point numbers.

Uploaded by

Paladin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

MIPS Floating Point Instructions Guide

The document provides an overview of MIPS floating point instructions, highlighting the need for floating point representation for very small or large numbers and the limitations in precision. It details the single and double precision formats, arithmetic and data movement instructions, and the process for conditional jumps in floating point operations. The document emphasizes the use of the IEEE 754 standard and MIPS-specific instructions for handling floating point numbers.

Uploaded by

Paladin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

11/9/2011

MIPS Floating Point Instructions


CS/COE 447

Why Floating Point?


• Sometimes need very small, or very large numbers? Non-integers?
▫ “1.1” or “2.99792E10”
• Not always precise. Not all numbers can be represented
▫ Repeating digits
 E.g., in base 10: 1/3 = 0.33333...

▫ Lack of precision
 E.g., 1.2345678901234567890123456789 may not “fit” in the

storage space allocated for the floating point number


• Single precision: 32-bits used to represent a number.
▫ “float” in C
• Double precision: 64-bits used to represent a number.
▫ “double” in C
• IEEE 754 standard

1
11/9/2011

Single Precision Floating Point Format


sign exponent fraction
0 00000000 0000000000000000 0000000

32 bits
• Sign: whether # is positive or negative
• Exponent: makes value large or small
• Fraction: the actual “number”
• Value: -1sign∙ [Link]∙2(exponent-127)
▫ Special values exist for ±∞, NaN (not a number)
▫ There are some other exceptions/issues

Overview of MIPS Floating Point


Instructions
• MIPS provides several instructions for floating point numbers
▫ Arithmetic
▫ Data movement (memory and registers)
▫ Conditional jumps
• FP instructions work with a different bank of registers
▫ Registers are named $f0 to $f31
▫ $f0 is not special (can hold any value, not just zero)
▫ “Coprocessor 1” tab in MARS
• There are instructions for single precision and double
precision numbers (we will only use single precision)
▫ Double precision numbers use only even numbered registers
▫ Single precision instructions end with “.s” (e.g. add.s)
▫ There is generally a corresponding double precision instruction,
which ends with “.d”

2
11/9/2011

Arithmetic Instructions

• add.s $f0, $f1, $f2 $f0 := $f1 + $f2


• sub.s $f0, $f1, $f2 $f0 := $f1 - $f2
• mul.s $f0, $f1, $f2 $f0 := $f1 * $f2
• div.s $f0, $f1, $f2 $f0 := $f1 / $f2
• abs.s $f0, $f1 $f0 := |$f1|
• neg.s $f0, $f1 $f0 := -$f1

Data Movement Instructions


• Memory Transfer Instructions
▫ l.s $f0, 100($t2) load word into $f0 from address $t2+100
▫ s.s $f0, 100($t2) store word from $f0 into address $t2+100
• Data Movement between registers
▫ mov.s $f0, $f2 move between FP registers
▫ mfc1 $t1, $f2 move from FP registers (no conversion)
▫ mtc1 $t1, $f2 move to FP registers (no conversion)
• Data conversion
▫ cvt.w.s $f2, $f4 convert from single precision FP to integer
▫ cvt.s.w $f2, $f4 convert from integer to single precision FP

3
11/9/2011

Conditional Jumps
• Conditional jumps are performed in two stages
1. Comparison of FP values sets a code in a special register
2. Branch instructions jump depending on the value of the
code
• Comparison
▫ [Link].s $f2, $f4 if $f2 == $f4 then code = 1 else code = 0
▫ [Link].s $f2, $f4 if $f2 <= $f4 then code = 1 else code = 0
▫ [Link].s $f2, $f4 if $f2 < $f4 then code = 1 else code = 0
• Branches
▫ bc1f label if code == 0 then jump to label
▫ bc1t label if code == 1 then jump to label

You might also like