Real Number Representation
Budget: $30 – $250 USD
Mars Mips Assembly
Implement the following in MIPS assembly (You can write it all in a single file or you can use multiple files). In addition, add clarity for the user. For example, have user input prompts and include newline for print outs.
Use I/O to have the user input a real number in string format. Translate that into integers using a modified atoi function from previous lab (now instead of translating an integer, you need to translate a real number). The translated number should be stored into two registers. For example, if the user inputted 23.43, then after translation, one register should have 23, and one register should have 43.
Note: You will need to figure out how many decimal places the radix point moved for the fractional portion in terms of base 10. For the above example, for 43, you should have a counter that understands the decimal point was moved two times to the right, in base 10, for 0.43 to be represented as 43. While you don’t need the information for this part, you will need this scaling factor in step 2 to get the correct bit pattern of 0.43.
In the console window, display, in decimal notation, the contents of the two registers. If you did not finish previous atoi lab, you can directly ask the user to input the two numbers, as integers, and move to the second portion. You will not receive credit for problem 1.
Convert user’s number into a fixed decimal notation in which 8 bits are used to store the integer portion of the number and 8 bits are used to store the fractional portion. Use a resolution shift of 8 bits. This information is to be stored in one register or one chunk of 32 bit memory. For example, decimal number 3.4526 will be store as the following format:
0000 0000 0000 0000 0000 0011.0111 0011
Note: The integer portion is stored in the left 8 bits of the right most 16 bits. The fractional portion is stored in the least significant portion of the lower 8 bits of the right most 16 bits. The left most 16 bits of 0’s are padding. Note: The radix point is not taking up a bit of space in memory or register. It is implicit in the formatting.
In the console window, display, in binary notation, the contents of the register. Use syscall 35 to print out in binary.
Ask user for second real number. Change this second real number into fixed point decimal notation of 16.16, using a resolution of 16 bits. Add this number with the first input by using ADD instruction. For example, if the first user input is 23.43 and second user input is 45.23, then the sum should be 68.66 (might be slightly different due to truncation).
Display the sum, in binary notation, to the console window.
Implement the following in MIPS assembly (You can write it all in a single file or you can use multiple files). In addition, add clarity for the user. For example, have user input prompts and include newline for print outs.
Use I/O to have the user input a real number in string format. Translate that into integers using a modified atoi function from previous lab (now instead of translating an integer, you need to translate a real number). The translated number should be stored into two registers. For example, if the user inputted 23.43, then after translation, one register should have 23, and one register should have 43.
Note: You will need to figure out how many decimal places the radix point moved for the fractional portion in terms of base 10. For the above example, for 43, you should have a counter that understands the decimal point was moved two times to the right, in base 10, for 0.43 to be represented as 43. While you don’t need the information for this part, you will need this scaling factor in step 2 to get the correct bit pattern of 0.43.
In the console window, display, in decimal notation, the contents of the two registers. If you did not finish previous atoi lab, you can directly ask the user to input the two numbers, as integers, and move to the second portion. You will not receive credit for problem 1.
Convert user’s number into a fixed decimal notation in which 8 bits are used to store the integer portion of the number and 8 bits are used to store the fractional portion. Use a resolution shift of 8 bits. This information is to be stored in one register or one chunk of 32 bit memory. For example, decimal number 3.4526 will be store as the following format:
0000 0000 0000 0000 0000 0011.0111 0011
Note: The integer portion is stored in the left 8 bits of the right most 16 bits. The fractional portion is stored in the least significant portion of the lower 8 bits of the right most 16 bits. The left most 16 bits of 0’s are padding. Note: The radix point is not taking up a bit of space in memory or register. It is implicit in the formatting.
In the console window, display, in binary notation, the contents of the register. Use syscall 35 to print out in binary.
Ask user for second real number. Change this second real number into fixed point decimal notation of 16.16, using a resolution of 16 bits. Add this number with the first input by using ADD instruction. For example, if the first user input is 23.43 and second user input is 45.23, then the sum should be 68.66 (might be slightly different due to truncation).
Display the sum, in binary notation, to the console window.