I need help coming up with a MIPS program for this.
1.3. Overview
For this assignment you will be writing a program the asks the user to enter a decimal number
and stores it in IEEE 754 single-precision floating point representation. You will then parse the
IEEE 754 representation to extract the different pieces (sign, exponent, and significand)
You do not have to convert the input to IEEE 754 representation manually. Just use the syscall to
read a float. This will automatically store the value in IEEE 754 format for you. You can then
copy the value to a normal 32-bit register to perform the different bit manipulations to extract
each piece.
After the initial reading in of the floating point value and moving the value to a standard register
you should not use the floating point registers again. Do not use any of the floating point
operations to find the sign, or anything else.
All of the parsing and calculations should be done using various bit manipulations operations
(i.e. bitshifts, maskings, etc). Remember beyond the initial reading of the floating point value
and moving it to a standard register your program should not touch the floating point registers
again.
Your program does not need to handle any of the special cases of floating point numbers like
NaN, infinity, -infinity, 0 or -0.
1.4. Task 1: Main Procedure
Your first task is to collect is to create a loop for your program. Ask user to enter "Do you want
to do it again?" in a Dialog box. Hint: Use syscall 50. If the user answers YES repeat the process.
NO or Cancel, exit the program.
1.5. Task 2: Take User Input Procedure
void read_float()
Next, take user input and store it in memory. Prompt the user to enter a floating point value as a
decimal number. Then, store the input value in a single precision floating point register. In a
DialogBox (syscall 52), Display a string with info about the program ex: "Welcome to the " and
capture a user input. The input should be a floating point number.
You MUST store input into memory space (ieee). To do this, first move your captured input
from the f0 floating point register to a regular temporary register using the following call:
Now, you should be able to store the value into the ieee variable in memory.
The procedure should have the following signature:
1.6. Task 3: Print the sign
void print_sign(ieee)
Your next task is to create a procedure called print_sign that will extract and interpret the sign bit
of the IEEE 754 single precision floating point number. The floating point number is the value
you collected from Task 2.
Your function will take the value as a 32-bit number in a non-floating point register (i.e. $a0).
Remember, this value is stored in your ieee memory space. You should use bit manipulations
(i.e. shifting, masking, etc) to determine the value of the sign bit. If the sign bit is a 1 your
function should print the '-' character. If it is a 0 your function should print the '+' character.
The procedure should have the followi.
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
1. I need help coming up with a MIPS program for this.
1.3. Overview
For this assignment you will be writing a program the asks the user to enter a decimal number
and stores it in IEEE 754 single-precision floating point representation. You will then parse the
IEEE 754 representation to extract the different pieces (sign, exponent, and significand)
You do not have to convert the input to IEEE 754 representation manually. Just use the syscall to
read a float. This will automatically store the value in IEEE 754 format for you. You can then
copy the value to a normal 32-bit register to perform the different bit manipulations to extract
each piece.
After the initial reading in of the floating point value and moving the value to a standard register
you should not use the floating point registers again. Do not use any of the floating point
operations to find the sign, or anything else.
All of the parsing and calculations should be done using various bit manipulations operations
(i.e. bitshifts, maskings, etc). Remember beyond the initial reading of the floating point value
and moving it to a standard register your program should not touch the floating point registers
again.
Your program does not need to handle any of the special cases of floating point numbers like
NaN, infinity, -infinity, 0 or -0.
1.4. Task 1: Main Procedure
Your first task is to collect is to create a loop for your program. Ask user to enter "Do you want
to do it again?" in a Dialog box. Hint: Use syscall 50. If the user answers YES repeat the process.
NO or Cancel, exit the program.
1.5. Task 2: Take User Input Procedure
void read_float()
Next, take user input and store it in memory. Prompt the user to enter a floating point value as a
decimal number. Then, store the input value in a single precision floating point register. In a
DialogBox (syscall 52), Display a string with info about the program ex: "Welcome to the " and
capture a user input. The input should be a floating point number.
You MUST store input into memory space (ieee). To do this, first move your captured input
from the f0 floating point register to a regular temporary register using the following call:
Now, you should be able to store the value into the ieee variable in memory.
The procedure should have the following signature:
1.6. Task 3: Print the sign
2. void print_sign(ieee)
Your next task is to create a procedure called print_sign that will extract and interpret the sign bit
of the IEEE 754 single precision floating point number. The floating point number is the value
you collected from Task 2.
Your function will take the value as a 32-bit number in a non-floating point register (i.e. $a0).
Remember, this value is stored in your ieee memory space. You should use bit manipulations
(i.e. shifting, masking, etc) to determine the value of the sign bit. If the sign bit is a 1 your
function should print the '-' character. If it is a 0 your function should print the '+' character.
The procedure should have the following signature:
Remember, the sign bit in an IEEE 754 floating point number is the most significant bit.
1.7. Task 4: Print the exponent
void parse_exp(ieee)
Your next task is to create a procedure called parse_exp that will extract and interpret the
exponent bits of the IEEE 754 single precision floating point number. Your function will take the
value as a 32-bit number in a non-floating point register (i.e. $a0). Next it will need to isolate the
bits representing the exponent and interpret those bits as an unsigned integer. Finally, you will
need to subtract the bias to recover the true exponent value as a signed integer. This is the value
that should be returned.
The procedure should have the following signature:
Remember the exponent is the 8 bits immediately following the sign bit.
1.8. Task 5: Print the significand
void print_significand(ieee)
Your next task is to create a procedure called print_significand that will extract the mantissa of
the IEEE 754 single precision floating point number. Your function will take the value as a 32-
bit number in a non-floating point register (i.e. $a0). Next it will need to isolate the bits
representing the mantissa.
The procedure should have the following signature:
Remember the mantissa is the low order 23 bits and you will need to add the implied 1.
1.9. Task 6: Print value store from Task 2
Finally, print the output you captured in Task 2 in IEEE 32 bit form
Here is what i have so far please help
# Author:
# Date: March 2023
# Description: A program that reads an IEEE 754 single-precision floating-point number in
decimal form from the user, and prints its sign, exponent, significand, and hex representation.
.macro print_str (%string)
3. la $a0, %string
li $v0, 4
syscall
.end_macro
.globl read_float, print_sign, parse_exp, print_exp, print_significand, main
# Data for the program goes here
.data
ieee: .word 0 # store your input here
again: .asciiz "Do you want to do it again?"
prompt: .asciiz "Enter an IEEE 754 floating point number in decimal form: "
res_sign: .asciiz "nThe sign is: "
new_line: .asciiz "n"
expoBias: .asciiz "nExpo with bias: "
expoNoBias: .asciiz "nExpo without bias: "
manti: .asciiz "nMantissa: "
sieee: .asciiz "nIEEE-754 Single Prec: "
.text # Code goes here
main:
loop:
print_str(prompt)
syscall # pop up gui
l.s $f0, 0($v0) # read user input as a float
mfc1 $t0, $f0 # copy register $f0 to $t0
sw $t0, ieee # store value in ieee variable in memory
jal print_sign # call print_sign procedure
jal parse_exp # call parse_exp procedure
jal print_exp # call print_exp procedure
jal print_significand # call print_significand procedure
print_str(sieee) # print IEEE number label
mfc1 $t0, $f0 # copy register $f0 to $t0
print_hex_float: # print IEEE number in hex
print_str(new_line)
li $t1, 8 # 8 nibbles to print
li $t2, 0 # counter
print_hex_digit:
srl $t3, $t0, 28 # shift right 28 bits to get a nibble
4. andi $t3, $t3, 0xf # mask to get the nibble
addi $t3, $t3, 48 # add offset to get ASCII code
add $t0, $t0, $t0 # shift left 1 bit
addi $t2, $t2, 1 # increment counter
print_str($t3) # print nibble
bne $t2, $t1, print_hex_digit # continue if not done
exit_loop:
print_str(new_line)
print_str(again)
syscall # Dialog box with Yes/No/Cancel options
beqz $v0, exit_main # cancel or no: exit the program
j loop # yes: repeat the loop
exit_main:
li $v0, 10 # 10 is the exit program syscall
syscall # execute call
# Procedure void read_float()
# Functional Description: Reads input from user using a pop-up GUI.
# It stores the captured value in ieee memory space.
# Argument parameters: None
# Return Value: None
read_float
In the tool below, "significand" is another name for the mantissa.
Input Waldo Weber CS2810 Spring2018 Welcome to the IEEE Parser Enter a decimal number:
OK Cancel
Exponent 00000000
Significand
1.9.1. Sample Output Negative sign: 0x00000001 Expo with bias: 0x00000081 Expo without
bias: 0x00000002 Mantissa: Ox00180000 IEEE-754 Single Prec: 0xc0980000
1.9.1.1. If your answer is YES Continue running the program Negative sign: 0x00000001 Expo
with bias: 0x00000081 Expo without bias: 0x00000002 Mantissa: Ox00180000 IEEE-754 Single
Prec: Oxc0980000 Expo without bias: 000000002 Mantissa: 0x00180000 IEEE-754 Single Prec:
5. Oxc0980000 Positive sign: 000000000 Expo with bias: 0x00000086 Expo without bias:
0x00000007 Mantissa: Ox00484000 IEEE-754 Single Prec: 0x43484000 1.9.1.2. If your answer
is NO Exit the program IEEE-754 Single Prec: 0x43484000 -- program is finished running .-