Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In assembly language (MIPS), create the function aTof which will parse a buffer. A parse will find a floating point number. Your program needs to
In assembly language (MIPS), create the function aTof which will parse a buffer.
A parse will find a floating point number. Your program needs to print these floats out to the screen. Copy the following between the >21.45 blah blah blah 43.0003 61 and 0.03
Some extra pointers to help:
Floating point operations must be done with the coprocessor, which has its own set 3 of registers, $f0 to Sf31. An integer can be 4 moved to a floating-point register, once there it must be converted to IEEE float standard. The code to the right demonstrates this: . data 2 An Int: .word 333 .text lw $t1, An Int #load our integer mtc1 $t1, $f1 #move it ot a floating point register cvt, s.w $f1, $f1 #convert it into a single precision (float) li, st1, 10 #same as above , f2 will contain 10.0 cvt.s.w $12, $E2 .2 When parsing a float from the text input consider the following algorithm div . s $fl, $f1, $f2 #single precision #shifts the decimal point by 1 unit (float) division 5 li $v0,2 mov.s $f12, $fi syscall #print it out For each digit shift left by multiplying by 10, same as parsing an int. If there is a decimal then count N, how many digits we shift from the decimal. Then convert this integer to a float and then divide by N*10.0 E.g. 101.22 is parsed to an integer of 10122, we count 2 digits after the radix this is N. After conversion to a float, 10122.0 we divide by 2*10 yielding 101.22. Floating point operations must be done with the coprocessor, which has its own set 3 of registers, $f0 to Sf31. An integer can be 4 moved to a floating-point register, once there it must be converted to IEEE float standard. The code to the right demonstrates this: . data 2 An Int: .word 333 .text lw $t1, An Int #load our integer mtc1 $t1, $f1 #move it ot a floating point register cvt, s.w $f1, $f1 #convert it into a single precision (float) li, st1, 10 #same as above , f2 will contain 10.0 cvt.s.w $12, $E2 .2 When parsing a float from the text input consider the following algorithm div . s $fl, $f1, $f2 #single precision #shifts the decimal point by 1 unit (float) division 5 li $v0,2 mov.s $f12, $fi syscall #print it out For each digit shift left by multiplying by 10, same as parsing an int. If there is a decimal then count N, how many digits we shift from the decimal. Then convert this integer to a float and then divide by N*10.0 E.g. 101.22 is parsed to an integer of 10122, we count 2 digits after the radix this is N. After conversion to a float, 10122.0 we divide by 2*10 yielding 101.22Step 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