CC2032 COAL Lab # 07
CC2032 COAL Lab # 07
The encodings of IEEE 754 floating-point numbers are shown below. Other features of IEEE 754
are special symbols to represent unusual events. For example, instead of interrupting on a divide
by 0, software can set the result to a bit pattern representing -∞ or +∞; the largest exponent is
reserved for these special symbols. When the programmer prints the results, the program will
print an infinity symbol. IEEE 754 even has a symbol for the result of invalid operations, such as
0/0 or subtracting infinity from infinity. This symbol is NaN, for Not a Number. The purpose of
NaNs is to allow programmers to postpone some tests and decisions to a later time in the
program when they are convenient.
3. Floating-Point Instructions in MIPS
MIPS supports the IEEE 754 single precision and double precision formats with these
instructions:
6. Task # 1: Run the following MIPS32 program and observe the values in
floating registers.
.data
num1: .float 3.5 # First floating-point number
num2: .float 2.25 # Second floating-point number
result: .float 0 # Variable to store the result
.text
.globl main
main:
# Load the first floating-point number into f0
lwc1 $f0, num1
# Exit program
li $v0, 10
syscall
Observation and Analysis:
Q1. What is expected result after addition (using calculator)?
Q2. Calculate the single precision floating point representation of given operands: A = 3.5
and B = 2.25. Present the calculated result in hexadecimal format and match with the value
stored in data memory.
Operand A
Sign Exponent Fraction
Hexadecimal =
Operand B
Sign Exponent Fraction
Hexadecimal =
Q3. What is value of floating point addition result stored in $f2 floating point register?
Q4. Convert the result of $f2Hex into decimal and verify if the result match the calculated
value of operands.
Q6. After the program finished, at which data memory location the result of addition is
stored? How is that address computed?
7. Task # 1: Run the following MIPS32 program and observe the values in
floating registers.
.data
num1: .float 7.5 # First floating-point number
num2: .float 3.25 # Second floating-point number
result: .float 0 # Variable to store the result
.text
.globl main
main:
# Load the first floating-point number into f0
lwc1 $f0, num1
# Exit program
li $v0, 10
syscall
Observation and Analysis:
Q1. What is expected result after subtraction (using calculator)?
Q2. Calculate the single precision floating point representation of given operands: A = 3.5
and B = 2.25. Present the calculated result in hexadecimal format and match with the value
stored in data memory.
Operand A
Sign Exponent Fraction
Hexadecimal =
Operand B
Sign Exponent Fraction
Hexadecimal =
Q3. What is value of floating point addition result stored in $f2 floating point register?
Q4. Convert the result of $f2Hex into decimal and verify if the result match the calculated
value of operands.