Computer Architecture Lecture 9: MIPS Instruction Set
24 Questions
3 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the format of the instruction beq rs, rt, label?

  • op6 = 4, rs5, 0, imm16
  • op6 = 2, rs5, rt5, imm16
  • op6 = 5, rs5, rt5, imm16
  • op6 = 4, rs5, rt5, imm16 (correct)
  • What is the result of the instruction slt $t0,$s1,$s0 when $s0 = 1 and $s1 = -1 = 0xffffffff?

  • $t0 = 1 (correct)
  • $t0 = -1
  • $t0 = undefined
  • $t0 = 0
  • What is the purpose of the 'sa' field in MIPS instructions?

  • Specifies the shift amount (correct)
  • Specifies the operation code
  • Specifies the function code
  • Specifies the register indices
  • What is the result of the instruction sltu $t0,$s0,$s1 when $s0 = 1 and $s1 = -1 = 0xffffffff?

    <p>$t0 = 0</p> Signup and view all the answers

    What is the meaning of the instruction bgez rs, label?

    <p>branch if rs &gt;= 0</p> Signup and view all the answers

    What is the difference between the 'add' and 'addu' instructions?

    <p>Addu does not cause an arithmetic exception, while add does.</p> Signup and view all the answers

    What is the format of the instruction j label?

    <p>op6 = 2, imm26</p> Signup and view all the answers

    What is the purpose of the 'funct' field in MIPS instructions?

    <p>Specifies the function code</p> Signup and view all the answers

    What is the purpose of the 'Op' field in MIPS instructions?

    <p>Specifies the operation code</p> Signup and view all the answers

    What is the meaning of the instruction bltz rs, label?

    <p>branch if rs &lt; 0</p> Signup and view all the answers

    How many registers are there in MIPS32?

    <p>32 general-purpose registers</p> Signup and view all the answers

    What is the purpose of the 'Rs' and 'Rt' fields in MIPS instructions?

    <p>Specify the source registers</p> Signup and view all the answers

    What is the purpose of the ' Rd' field in MIPS instructions?

    <p>Specifies the destination register</p> Signup and view all the answers

    What is the difference between the 'and' and 'nor' instructions?

    <p>And is used for bitwise AND, while nor is used for bitwise NOR</p> Signup and view all the answers

    What is the purpose of the 'immediate' field in I-Type instructions?

    <p>Specifies a 16-bit immediate constant</p> Signup and view all the answers

    How many instruction formats are there in MIPS?

    <p>3</p> Signup and view all the answers

    What is the purpose of the sll instruction in MIPS?

    <p>To shift the bits of the register left</p> Signup and view all the answers

    How can you multiply a number by 36 using shift and add instructions?

    <p>By factoring 36 into (4 + 32) and using the distributive property of multiplication</p> Signup and view all the answers

    What is the purpose of the mult instruction in MIPS?

    <p>To perform signed multiplication</p> Signup and view all the answers

    What is the purpose of the mflo instruction in MIPS?

    <p>To move data from LO to a register</p> Signup and view all the answers

    What is the limitation of the R-type shift instructions in MIPS?

    <p>They have a 5-bit shift amount constant</p> Signup and view all the answers

    How can you multiply a number by 31 using shift and add instructions?

    <p>By shifting left by 5 and subtracting the original number</p> Signup and view all the answers

    What is the purpose of the div instruction in MIPS?

    <p>To perform signed division</p> Signup and view all the answers

    What happens if the divisor is 0 in a division operation in MIPS?

    <p>The result is unpredictable</p> Signup and view all the answers

    Study Notes

    MIPS Instruction Set Architecture

    • MIPS is a type of Reduced Instruction Set Computer (RISC)
    • All instructions are typically 32-bits wide
    • Arithmetic instructions are register-to-register, operands are read from registers, and the result is stored in a register
    • MIPS has 32 general-purpose integer and 32 floating-point registers

    General Purpose Registers (GPRs)

    • There are 32 GPRs in MIPS, each 32-bits wide
    • The assembler uses the dollar notation to name registers, e.g., 0,0, 0,1, ..., $31
    • Register $0 is always zero, and any value written to it is discarded

    Register Naming Convention

    • Software defines names for registers to standardize their use in programs
    • Registers 8−8-8−15 are called t0−t0-t0−t7, used for temporary values
    • Registers 16−16-16−23 are called s0−s0-s0−s7, used for saved registers
    • Registers have specific names and uses, such as v0−v0-v0−v1 for result values, a0−a0-a0−a3 for arguments, and $ra for return addresses

    Instruction Format

    • There are three instruction formats: R-type, I-type, and J-type
    • R-type format is used for register-to-register instructions
    • I-type format is used for instructions with a 16-bit immediate constant
    • J-type format is used for jump instructions

    Instruction Examples

    • Arithmetic instructions: add, addu, sub, subu, with R-type format
    • Logical instructions: and, or, xor, nor, with R-type format
    • Shift instructions: sll, srl, with R-type format and a 5-bit shift amount field
    • Jump and branch instructions: j, beq, bne, blez, bltz, bgez, with J-type format

    Shifting and Multiplication

    • Shifting can be used to perform multiplication by a power of 2
    • Example: multiplying $s1 by 36 using sll and add instructions

    Assignment

    • Multiply $s1 by 26 using shift and add instructions
    • Multiply $s1 by 31 using shift and sub instructions

    Multiplication and Division

    • Signed and unsigned multiplication: mult, multu, with a 64-bit result
    • Signed and unsigned division: div, divu, with a 32-bit quotient and remainder
    • Moving data between LO and HI registers and general-purpose registers

    Constants

    • Constants are used frequently in programs
    • R-type shift instructions have a 5-bit shift amount constant
    • Other instructions may need a constant, but the method is not specified

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    This quiz covers the MIPS instruction set architecture, a RISC-based language understood by computers. It explores the characteristics of arithmetic instructions and the use of general purpose registers.

    More Like This

    MIPS Architecture Overview
    5 questions

    MIPS Architecture Overview

    EnergySavingVuvuzela avatar
    EnergySavingVuvuzela
    MIPS Instruction Formats
    12 questions
    MIPS Instruction Set Cheat Sheet
    6 questions
    MIPS-32 Instruction Set Architecture Quiz
    20 questions
    Use Quizgecko on...
    Browser
    Browser