Preview

MIPS assembly language

Satisfactory Essays
Open Document
Open Document
610 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
MIPS assembly language
EE 361 Homework 3
Total points = 9
Problem A. [2 pts] What are the MIPS assembly language instructions for the following words (see MIPS reference card at the front of the textbook).
Instruction 1: 100011 00011 00100 00000 00000 000100

Instruction 2: 000000 01101 00010 00110 00000 100000

Instruction 3: 000000 00001 00010 00011 00000 100010

Instruction 4: 000010 00000 00000 00000 00000 001100
This exercise is similar to what a CPU does when it decodes an instruction. It first looks in the opcode field to determine the instruction and its type. Then based on this, it recognizes the rest of the fields of the instruction.
Problem B [2 pt]. Consider the following C language for-loop: for (i = k; i < k+20; i++) j = j + i;

The following is a MIPS assembly language implementation of the for-loop assuming that $3, $4, and $5 are used to store i, j, and k, respectively.

add $3,$0,$5 # i = k;

Loop: addi $1,$5,20 # branch if i >= k+20 slt $1,$3,$1 # $1 = 1 if i < k+20 beq $1,$0,Skip # if $1 == 0 (i.e., i >= 100) then skip for-loop

add $4,$4,$3 # j = j + i; addi $3,$3,1 # i++; beq $0,$0,Loop # go back to beginning of for-loop
Skip:

Write the machine code for the MIPS assembly language instructions. You may use decimal numbers (positive and negative ones) to fill in the fields. Note that all instructions and their machine code versions can be found in front of the green card and in Appendix B.10, especially from pages B-45 to B-73).

Problem C [2 pts]: Implement the following C for loop in MIPS assembly language. Assume that variables x1 and x2 are realized by, respectively, $3 and $4. You may use $1, $2, $5, and $6 for temporary storage. Be sure to put in comments to explain your code.

x1 = 7; while (x1 < x2) { x2 = x2 + x1; x1 = x1 + 15; }
Problem D (3 pts total). The mcc compiler.
The MIPS processor has a

You May Also Find These Documents Helpful

  • Powerful Essays

    CODE FOR THE ABOVE FRAGMENT addi $t6, $zero, 101 # the loop termination value add $t0, $zero, $zero # i = 0 addi $t2, $a0, 0 # ptr to current A[i] addi $t3, $a1, 0 # ptr to current B[i] loop: lw $t4, 0($t3) # load B[i] add $t4, $t4, $s0 # B[i] + c sw $t4, 0($t2) # store in A[i] addi $t0, $t0, 1 # i++ addi $t2, $t2, 4 # ptr to next A[i] addi $t3, $t3, 4 # ptr to next B[i] bne $t0, $t6, loop # if i < 101, goto loop IF ANY QUERIES REGARDING CODE…

    • 107 Words
    • 1 Page
    Powerful Essays
  • Satisfactory Essays

    PT1420 Unit 8 Lab 8

    • 365 Words
    • 2 Pages

    Calculating a Running Total, page 201): Asks for input of a number 5 times then adds all numbers into one total sum, example 2,4,6,8,10 = 30…

    • 365 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Nt1210 Chapter 1 Review

    • 1315 Words
    • 6 Pages

    6. A user file has opened a word processor, typed the numbers 123456789, and stored the document as a file called report 1. Which of the following determines, in part what bits the computer stores in the file to represent the text typed into the report.…

    • 1315 Words
    • 6 Pages
    Good Essays
  • Satisfactory Essays

    unit 7 assignment 1

    • 431 Words
    • 2 Pages

    7. Convert the While loop in the following code to a Do-While loop: int x;…

    • 431 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    CHAPTER3 REVEIW

    • 527 Words
    • 3 Pages

    6. A user has opened a word processor, typed the numbers 123456789, and stored the document as a file called report1. Which of the following determine, in part, what bits the computer stores in the file to represent the text typed into the report?…

    • 527 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    6. A user has opened a word processor, typed the numbers 123456789, and stored the document as a file called report1. Which of the following determines, in part, what bits the computer stores in the file to represent the text typed into the report?…

    • 856 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    18.Write a program to read a hex input and display it in binary. Page: 133…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    En1320 Unit 1 Research Paper 1

    • 27742 Words
    • 111 Pages

    computation are stored in registers R1 and R2, and the result of the computation is stored…

    • 27742 Words
    • 111 Pages
    Powerful Essays
  • Satisfactory Essays

    9.) A bug collector collects bugs every day for 7 days. Design a program that keeps a running total of the number of bugs collected during the 7 days. The loop should ask for the number of bugs collected each day, and when the loop is finished, the program should display the total number of bugs collected.…

    • 651 Words
    • 4 Pages
    Satisfactory Essays
  • Better Essays

    3) Look at the following pseudocode module header: Module myModule( Integer a, Integer b, Integer c) Now look at the following call to myModule: Call myModule( 3, 2, 1) When this call executes, what value will be stored in a? What value will be stored in b? What value will be stored in c?…

    • 1580 Words
    • 11 Pages
    Better Essays
  • Satisfactory Essays

    E4.6: The label array_x is the starting address of an array of 100 8bit elements.…

    • 900 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    Athabasca Assignment

    • 837 Words
    • 4 Pages

    * Go to MyMISLab and download the Exercise Data File: MIS11ch03 for this assignment from the Assignment 1 folder (after logging in, click Course Content, choose View All Content, then scroll…

    • 837 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Hipaa and Medical Records

    • 366 Words
    • 2 Pages

    Patients must also receive a privacy notice from covered entities letting their clients know their standard policies on sharing a patient’s health information and how a patient can exercise their rights. (U.S. Department of Health and Human Services 2006) Covered entities include: doctors, clinics, nursing homes, health insurance plans and health care clearinghouses. According to HIPAA, “the individual has a fundamental right to receive adequate notice of how a covered entity may use and disclose” their personal health information. The notice must contain, in plain language, the following:…

    • 366 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    Ecs1601 Week 2 Study Guide

    • 3089 Words
    • 13 Pages

    Dear Student The purpose of this tutorial letter is to provide you with the correct answers to the assignments. 1. The solutions to Assignments 03 and 04. Assignment 03 - Unique number 810132 Explanations 3.1 The correct alternative is (3)…

    • 3089 Words
    • 13 Pages
    Powerful Essays
  • Satisfactory Essays

    Copyright © 2012 Pearson Education, Inc. 0-4 2 Stored Program Concept A program can be encoded as bit patterns and stored i main memory. F d t d in i From th there, the CPU can then extract the instructions and execute them. In turn, the program to be executed can be altered easily.…

    • 783 Words
    • 4 Pages
    Satisfactory Essays

Related Topics