Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JUST DO QUESTION 2 PLEASE Floating Point 1. Using what you have learned in previous tutorials, you should be able to write a program that
JUST DO QUESTION 2 PLEASE
Floating Point 1. Using what you have learned in previous tutorials, you should be able to write a program that multiplies two floating point numbers together (See slides 36-40 in the notes on arithmetic) a. Literally this is just 1.s $f14, 2.5 1.5 $f18, 3.5 mul.s $f16, $f14, $f18 b. Except... it isn't. Unfortunately this is one place MARS differs from the book and SPIM . data a: .float 15.50 . text main: 1.8 SFO a mov.s $f12 $fo li $vo 2 syscall Will let you load a floating point number and then print it off If you wanted to read in from the console something like Svo 6 syscall mov.3 Sf2 $fo mov.s $112 SFO li $v0 2 syscall Will read in a value and print it off. Will read in a value and print it off. Modify those to hard code one value (say A), read in another from the console, put them in $f1, and $f3, multiply them together and print the result out. There are a couple of things you should play with. To see the state of floating point variables you inspect COPROC 1. Notice in (a) I have you separate your floating point values by 2 memory spaces. That isn't always necessary (so if you did everything in $f1, $f2, $f3 it would work fine) But the following doesn't work text 1.d $il, fpconst 1.d $12 Epconst2 mul.s $3, $81, $2 .data fpconst: float 1.2345 fpconst2: float 2.3456 Because those are now loading doubles (poke around with this to make it work, but there are a lot of things happening, you need to use mul.d, the variables are now doubles not floats, and you can use sequential odd numbered memory addresses) .text 1.d $82, fpconst 1.d $f4, fpconst2 mul.d $f6, $f2, $f4 .data fpconst: .double 1.2345 fpconst2: .double 2.3456 is a working version with double precision 2. Convert your program to use integers, experiment with signed and unsigned (See slide 11 of lecture 4) a. The opcode for this is mul rs, rt with two operands (you obviously need to set rs and rt to something such as $vo $v1) b. Once you execute the instruction you get a result that is now in two registers (hi and low), you can move them one by one into rd to test for overflow and underflow, again, see slide 11. Submission for the Floating point part: (You can do this all in one.asm file) a) A program that hard codes one FP value, reads in another from the user, multiplies them together and prints the result. b) Do the same thing, but for double precision c) Working with unsigned integers, look at what happens when you multiply two numbers together that get you a result larger than 2432, and write code that will detect the overflow in the 'hi' register Arrays. Goals for Today. Floating Point 1. Using what you have learned in previous tutorials, you should be able to write a program that multiplies two floating point numbers together (See slides 36-40 in the notes on arithmetic) a. Literally this is just 1.s $f14, 2.5 1.5 $f18, 3.5 mul.s $f16, $f14, $f18 b. Except... it isn't. Unfortunately this is one place MARS differs from the book and SPIM . data a: .float 15.50 . text main: 1.8 SFO a mov.s $f12 $fo li $vo 2 syscall Will let you load a floating point number and then print it off If you wanted to read in from the console something like Svo 6 syscall mov.3 Sf2 $fo mov.s $112 SFO li $v0 2 syscall Will read in a value and print it off. Will read in a value and print it off. Modify those to hard code one value (say A), read in another from the console, put them in $f1, and $f3, multiply them together and print the result out. There are a couple of things you should play with. To see the state of floating point variables you inspect COPROC 1. Notice in (a) I have you separate your floating point values by 2 memory spaces. That isn't always necessary (so if you did everything in $f1, $f2, $f3 it would work fine) But the following doesn't work text 1.d $il, fpconst 1.d $12 Epconst2 mul.s $3, $81, $2 .data fpconst: float 1.2345 fpconst2: float 2.3456 Because those are now loading doubles (poke around with this to make it work, but there are a lot of things happening, you need to use mul.d, the variables are now doubles not floats, and you can use sequential odd numbered memory addresses) .text 1.d $82, fpconst 1.d $f4, fpconst2 mul.d $f6, $f2, $f4 .data fpconst: .double 1.2345 fpconst2: .double 2.3456 is a working version with double precision 2. Convert your program to use integers, experiment with signed and unsigned (See slide 11 of lecture 4) a. The opcode for this is mul rs, rt with two operands (you obviously need to set rs and rt to something such as $vo $v1) b. Once you execute the instruction you get a result that is now in two registers (hi and low), you can move them one by one into rd to test for overflow and underflow, again, see slide 11. Submission for the Floating point part: (You can do this all in one.asm file) a) A program that hard codes one FP value, reads in another from the user, multiplies them together and prints the result. b) Do the same thing, but for double precision c) Working with unsigned integers, look at what happens when you multiply two numbers together that get you a result larger than 2432, and write code that will detect the overflow in the 'hi' register Arrays. Goals for TodayStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started