What is the corresponding mips code for c statements

Assignment Help Computer Engineering
Reference no: EM131849210

Assignment: Computer Architecture and Organization

Questions

1) This problem deals with translating from C to MIPS assembly. Assume that the variables f, g, h, i and j are assigned to registers $s0, $s1, $s2, $s3 and $s4, respectively. In other words, the corresponding MIPS registers hold the values for their counterpart variables. What is the corresponding MIPS code for C statements f=g+h+i+j +1; , f=g+ (h-5) ; and f=i-f;? Comment your MIPS code to explain the computation.

2) This problem deals with translating from MIPS to C. Assume that the variables f, g, h, i and j are assigned to registers $s0, $s1, $s2, $s3 and $s4, respectively. In other words, the corresponding MIPS registers hold the values for their counterpart variables. What is the corresponding C code for the following MIPS instructions?

add $s0, $s1, $s2
sub $s0, $s3, $s0
addi $s0, $s0, 4
addi $s4, $s2, -1

3) This problem deals with translating from C to MIPS assembly. Assume that the variables f, g, h, i and j are assigned to registers $s0, $s1, $s2, $s3 and $s4, respectively. In other words, the corresponding MIPS registers hold the values for their counterpart variables. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively.

a. For the C statement f=-g-A [4] ; what is the corresponding MIPS assembly code? Comment your assembly code to explain the computation given in the C statement.

b. For the C statement B [ 8 ] =A [i-j ] ; what is the corresponding MIPS assembly code? Comment your assembly code to explain the computation given in the C statement.

4) This problem deals with translating from MIPS to C. Assume that the variables f, g, h, i and j are assigned to registers $s0, $s1, $s2, $s3 and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively.

a. For the assembly instructions below, what is the corresponding C statement(s)?

sll $tO, $s0, 2
add $tO, $s6, $t0 sll $t1, $s1, 2
add $t1, $s7, $t1
1w $s0, $0($t0)
addi $t2, $tO, 4
1w $tO, 0($t2)
add $tO, $tO, $s0
sw $tO, 0 ($t1)

b. Rewrite the above MIPS assembly code to minimize the number of assembly instructions (to the extent possible) to implement the same function.

c. Compare the number of registers being used between the given code and the code which you attempted to minimize for its instruction count.

5) This problem deals with translating from C to MIPS. Assume that the variables f, g, h, i and j are assigned to registers $s0, $s1, $s2, $s3 and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively. For the C statements f=f+A [2] ; and

B [8 ] =A [i] +A [j ] ; , write the corresponding MIPS code while keeping the register count being used to and instruction count at minimum.

6) This problem deals with analyzing the computation being performed by MIPS assembly code. Consider the MIPS assembly code fragment given below:

addi $tO, $s6, 4
add $t1, $s6, $0
sw $t1, 0($t0)
1w $tO, 0($t0)
add $s0, $t1, $t0

Assume that the registers $s0, $s1, $s2, and $s3 hold the values Ox0000000A, 0x00000014, 0x0000001 E, and 0x00000028, respectively. Also, assume that register $s6 holds the value Ox00000100, and the memory contents are as shown in the below table:

Memory Address

Value Stored

0x00000100

0x00000064

0x00000104

Ox00000008

0x00000108

Ox0000012C

Determine the value of $s0 upon executing the given assembly code. You must explain every computation state to reach your final value for the contents of $s0 register to receive credit.

Reference no: EM131849210

Questions Cloud

Identify the movie and provide a clip : Is there a particular movie (recent or past), that models teaching, and adult learning you have watched or heard about?
Common stock value-variable growth : Common stock value—Variable growth-Find the market value of? Lawrence's shares when dividends are expected to grow at 30?% annually for 3? years,
What is the range of fasting blood sugars : What is the range of fasting blood sugars for group A and group B? How stable is the range as a measure of variability? why?
Discuss one dimension from your educational experience : Tell me about a time, where you taught a real world problem to students or experienced a real world problem in a classroom setting.
What is the corresponding mips code for c statements : What is the corresponding MIPS code for C statements f=g+h+i+j +1; , f=g+ (h-5) ; and f=i-f;? Comment your MIPS code to explain the computation.
Copies of the same letter indistinguishable : How many different ways are there to arrange all letters in the word if copies of the same letter can be told apart?
Some new equipment to replace the existing equipment : Manny Kurr is considering the purchase of a some new equipment to replace the existing equipment currently being used.
What is the probability that the individual has a university : (A) What is the probability that the individual has a university degree and is married? (B) What is the probability that the individual has a university degree
Company plans to finance large project : A company plans to finance a large project that will last 5 years. The company will borrow $700,000 now to finance the project.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write an application with three buttons

Write an application with three buttons labeled Red, Green, and Blue that changes the background color of a panel in center of the frame to red, green or blue.

  Create a menu for xyz companys budgeting system

In this assignment, you must create a menu for XYZ Company's Budgeting System. The system is a stand-alone application that uses a Visual Basic front-end and a SQL Server database on the back-end.

  Write a program that displays a graphical seating chart

Write a program that displays a graphical, seating chart for a berth reservation. Create a class called Passenger (as in one who travels).

  What happens to a conditional branch instruction

Briefly highlight what happens to a conditional branch instruction as it passes through each stage of the MIPS 5-stage pipeline and undergoes dynamic branch prediction in a 0.25K direct mapped Buffer Target Cache.

  Explain structured walkthrough as part of quality assurance

Design a structured walkthrough as part of the quality assurance measures for your scenario application project. How a structured walkthrough would be initiate.

  Software measurement and software metrics

Explain whether the software measurement is equivalent to the software metrics? What makes them different? Explain the common software metrics which you already know, heard about or used?

  Design the given functions and call them in main

Design the following functions and call them in Main, int get_student_data(void): This function asks the user to enter the student ID, Quiz, Test, Recitation, Final scores etc and prints them in a file "Stu_score.txt". This function returns the num..

  Discuss the advantages and disadvantages of each approach

COMP247 Data Communications. What is the maximum data capacity for traffic between Hornsby and the City store?

  Simple annual interest and the remainder

She borrowed the maximum amount she could at 3.5% simple annual interest and the remainder at 7% simple annual interest. At the end of the first year, she owed $259 in interest. How much was borrowed at each rate?

  Write a program that plays popular scissor-rock-paper game

Write a program that plays the popular scissor-rock-paper game. (A scissor can cut a paper, a rock can knock a scissor, and a paper can wrap a rock.) The program randomly generates a number 0, 1, or 2 representing scissor, rock and paper.

  How the core issue depend on who wrote the code

how the core issue depend on who wrote the code

  Write down java application to accomplish

Ask users for the past 5 years of federal taxes they have paid, save this data to an array, search for largest and the smallest amount of tax, and display it to screen.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd