Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MIPS procedure toFloat to put a floating-point number into IEEE single-p

ID: 3565304 • Letter: W

Question

Write a MIPS procedure toFloat to put a floating-point number into IEEE single-precision format. The procedure takes three integers as input: $a0, $a1, $a3, which represents a floating-point number in this way:

If $a0 contains 0, the floating-point number is positive, else the floating-point number is negative.

The number stored in register $a1 is the integer part of the floating-point number, and

The number stored in register $a2 is the fraction part of the floating-point number.

Hint: For the fraction part, you can use the div rs rt instruction to divide 25 by 100. The fraction will be stored in the HI register, and you can use the mfhi instruction to retrieve the fraction. The procedure will return v0, which contains the IEEE single-precision pattern corresponding to the floating-point number represented by the three input numbers.

a) Declare and assign three variables, to store values for a0, a1 and a2. The variable for a0 should be assigned a value of 0, a1, 7 and a2, 5.

b) Declare four strings to indicate description of: decimal format, binary format, normalized format, and IEE format.                                                                                                                                                 

c) In your main program print the decimal values stored the variables created in (a) above. Your output should contain, on the same row, the corresponding decimal string declared in c above. You should print the decimal values with a dash between each value. For example 10-9-28.

d) Following your code in (c) above, create code to change the values of the printed decimal values so that this time the printed output is like a replica of (c) above but this time the values of 1, 23 and 24 are printed instead.

e) Write the code, jal toFloat at the end of printing the decimals from (c) above; that is, immediately before the code for (d) above. Write the code, # jal toFloat at the end of printing the decimals in e above. Notice that the second call is blocked out. We will unblock and call it later.

f) Below the code, #jal toFloat, declare the function toFloat as seen in example below. Write code to calculate the binary, normalized and IEE form of the input numbers.

g) Print the sign and magnitude version of the floating point number represented by 0,7,5. This is actually a binary format. Use the binary string declared in c above to describe this number when printing it out.

h) Print the normalized version of the floating-point number represented by 0, 7, 5. This is actually a binary format. Use the normalized string declared in c above to describe this number when printing it out.

i) Print the IEEE 754 (SP) version of the floating-point number represented by 0, 7, 5. Use the IEE string declared in (b) above to describe this number when printing it out.

Write a MIPS procedure toFloat to put a floating-point number into IEEE single-precision format. The procedure takes three integers as input: $a0, $a1, $a3, which represents a floating-point number in this way: If $a0 contains 0, the floating-point number is positive, else the floating-point number is negative. The number stored in register $a1 is the integer part of the floating-point number, and The number stored in register $a2 is the fraction part of the floating-point number. Hint: For the fraction part, you can use the div rs rt instruction to divide 25 by 100. The fraction will be stored in the HI register, and you can use the mfhi instruction to retrieve the fraction. The procedure will return v0, which contains the IEEE single-precision pattern corresponding to the floating-point number represented by the three input numbers. a) Declare and assign three variables, to store values for a0, a1 and a2. The variable for a0 should be assigned a value of 0, a1, 7 and a2, 5. b) Declare four strings to indicate description of: decimal format, binary format, normalized format, and IEE format. c) In your main program print the decimal values stored the variables created in (a) above. Your output should contain, on the same row, the corresponding decimal string declared in c above. You should print the decimal values with a dash between each value. For example 10-9-28. d) Following your code in (c) above, create code to change the values of the printed decimal values so that this time the printed output is like a replica of (c) above but this time the values of 1, 23 and 24 are printed instead. e) Write the code, jal toFloat at the end of printing the decimals from (c) above; that is, immediately before the code for (d) above. Write the code, # jal toFloat at the end of printing the decimals in e above. Notice that the second call is blocked out. We will unblock and call it later. f) Below the code, #jal toFloat, declare the function toFloat as seen in example below. Write code to calculate the binary, normalized and IEE form of the input numbers. toFloat code: g) Print the ½sign and magnitude½ version of the floating point number represented by 0,7,5. This is actually a binary format. Use the binary string declared in c above to describe this number when printing it out. h) Print the ½normalized version½ of the floating-point number represented by 0, 7, 5. This is actually a binary format. Use the normalized string declared in c above to describe this number when printing it out. i) Print the ½IEEE 754 (SP) version½ of the floating-point number represented by 0, 7, 5. Use the IEE string declared in (b) above to describe this number when printing it out.

Explanation / Answer

newline: .asciiz " " promptwhole: .asciiz "Enter the whole number part" promptdecimal: .asciiz "Enter the decimal part" .text toFloat: li $v0,4 # load 4 to print string la $a0,promptsign # print the prompt syscall li $v0,4 la $a0,newline syscall li $v0,5 # load 5 to read integer syscall move $t0,$v0 #move input to temporary register since we want it in $a0 but $a0 will be used next li $v0,4 la $a0,promptwhole syscall li $v0,4 la $a0,newline syscall li $v0,5 syscall move $a1,$v0 # move the result to $a0 li $v0,4 la $a0,promptdecimal syscall li $v0,4 la $a0,newline syscall li $v0,5 syscall move $a2,$v0 # move the result to $a2 move $a0,$t0 # move the first input result from temporary to $a0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote