Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create the MIPS version of the function: f = g + (h - i) + j Use the following values for the variables: g =

Create the MIPS version of the function: f = g + (h - i) + j Use the following values for the variables: g = 15, h = 14, i = 5, and j = 20 In order to place an immediate value into a register we have two options: The first is how the language actually handles it which is to use an addition instruction with a 0 at one of the operands: addi $s0, $zero, 10#$s0 = 10 + 0 = 10 The second is a shorthand instruction load immediate: li $s0, 10 # $s0 = 10 After getting the function itself working, lets print the result of the function. Since we are working with, and will want to print, an integer value then we will need to place a value of 1 into the $v0 register as found on the provided chart. We will then place the integer we wish to print into the $a0 register ( f in this case ). Again using the add instruction and the $zero register will let us move values between registers. Ex. destination = original + $zero We also have the option of a pseudo-instruction to perform the same operation in the move instruction: move $s0, $s1 # $s0 = $s1 Finally, we are ready to use the syscall command to have our value printed to the screen. Part 2: For this part we will repeat/copy what we have above and then modify that copy. Next we will take in two values from the user for use in the formula from part 1. We will replace h with 10 and j with 1 to keep things consistent. To take in an integer, we can see on the syscall chart that we must place a 5 in the $v0 register and then perform our syscall. We can then enter a value, with that value being stored in $v0 after the syscall. Take in both values and then using the same method from part 1, print the result. Part 3: Once we have the result of our two operations printed, youll notice that there is no spacing between the first output and the first input, so lets fix that. Before taking in the first number for part 2, insert a new line character using a similar method as printing an integer, but in this case using the code for printing a character as found on the chart of syscall codes. In order to specify which character to print, we will provide the decimal number of that character as found on the ASCII table, which one version is also provided. This will allow separation between your two results. Part 4: The final part of the assignment will be to close the program correctly, meaning it wont have the dropped off bottom portion mentioned in your programs output. In order to do this, wherever we want the program to terminate, we use the exit syscall as seen on the chart (use the first one).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Auditing and Assurance Services A Systematic Approach

Authors: William Messier, Steven Glover, Douglas Prawitt

9th edition

1308361491, 77862333, 978-1259248290, 9780077862336, 1259162346, 978-1259162343

More Books

Students also viewed these Accounting questions