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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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