






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Information about the MIPS instruction set, including opcode values, instruction formats for types A, B, C, and D, and examples of MIPS instructions and their corresponding pseudoinstructions. It also includes a problem set from a Computer Architecture course at Rose-Hulman Institute of Technology, which covers topics such as variable length instructions, addressing modes, and MIPS assembly language.
Typology: Summaries
1 / 10
This page cannot be seen from the preview
Don't miss anything!







Fall 2005-2006 Computer Science and Software Engineering Profs. Archana Chidanandan and Larry Merkle
Name:____________________________________________________
Instructions:
Authorized resources:
Unauthorized resources: You are NOT permitted to use any resources other than those identified above. In particular, you may NOT use books, notes, electronic files, calculators, PDAs, or computers.
Good luck!
Problem Number
Maximum Points
Points Earned
1a 12
1b 12
1c 8
1d 8
2a 12
2b 17
Total 99 + 1 bonus
Fall 2005-2006 Computer Science and Software Engineering Profs. Archana Chidanandan and Larry Merkle
Problems Problem 1a.[12 points] List the machine language fields and obtain the hexadecimal representation for the following MIPS instructions:
lw $t0, 4($t1) Opcode = 35; rs = $t1 = $9; rt = $t0 = $8; 16-bit signed immediate = 0x
0x8d
addi $s2, $s1, - Opcode = 8; rs = $s1 = $17; rt = $s2 = $18; 16-bit signed immediate = -
0x2232fffb
sub $t3, $t5, $a Opcode = 0; Funct = 34; rs = $t5 = $13; rt = $a0 = $4; rd = $t3 = $
0x01a
Problem 1b. [12 points]Give the MIPS assembly language statements represented by each of the following:
0x27a addiu $5, $29, 4 or addiu $a1, $sp,
0x001a srl $4, $26, 2 or srl $a0, $k0, 2
0x116a beq $11, $10, 4 or beq $t3, $t2, loop
Fall 2005-2006 Computer Science and Software Engineering Profs. Archana Chidanandan and Larry Merkle
Problem 2. You are designing an architecture with variable length instructions. Some instructions are 12 bits long, while others are 24 bits long. There are 8 general purpose registers and each of these registers is 12 bits wide. Addresses and immediates are also 12-bits wide. The instructions and their types are listed in the table below.
Instruction Type Action Length 1 Add rd, rs A Reg[rd] = Reg[rs] + Reg[rd] 12 bits 2 Sub rd, rs A Reg[rd] = Reg[rs] – Reg[rd] 12 bits 3 Jr rs A PC = Reg[rs] 12 bits 4 And rd, rs A Reg[rd] = Reg[rd] and Reg[rs]
12 bits
5 Or rd, rs A Reg[rd] = Reg[rs] or Reg[rd] 12 bits 6 Getinput rd, rs A Reg[rd] = SpecialRegister[rs]
12 bits
12 bits
8 Addi, rd, rs, 12-bit immediate
B Reg[rd] = Reg[rs] + 12-bit immediate
24 bits
9 Beq rd, rs, 12-bit address B If (Reg[rs] = = reg[rd]) PC = 12-bit address
24 bits
10 Bne rd, rs, 12-bit address B If (Reg[rs] != Reg[rd]) PC = 12-bit address
24 bits
11 Lw rd, 12-bit address (rs) B Reg[rd] = Mem[Reg[rs] + 12-bit address]
24 bits
12 Sw rd, 12-bit address (rs) B Mem[Reg[rs] + 12-bit address] = Reg[rd]
24 bits
13 Sl rd, rs, 5-bit immediate B If(5-bit immediate > 0) Reg[rd] = Reg[rs] << 5-bit immediate else Reg[rd] = Reg[rs] >> 5-bit immediate
24 bits
14 J 9-bit address C PC = PC[11:9] || 9-bit address
12 bits
15 Jal 9-bit address C PC = PC[11:9] || 9-bit address Reg[7] = PC
12 bits
16 Rfe C PC = EPC 12 bits 17 Slt rd, rs, rt D If(Reg[rs] < Reg[rt]) Reg[rd] = 1; Else Reg[rd] = 0
12-bits
Fall 2005-2006 Computer Science and Software Engineering Profs. Archana Chidanandan and Larry Merkle
a. [12 points] Show the instruction format for each type i.e. A, B, C, and D. Indicate clearly how many bits are allocated for each field. Hint: Start with the C and D types. One possible solution: A type format 11 9 8 6 5 3 2 0 Opcode rd rs Function field
B type format
C type format
D type format 11 9 8 6 5 3 2 0 Opcode rd rs rt
b. [17 points] For each of the instructions below, assign a value for the opcode field, as well as values for any fields that augment the opcode (e.g. the funct field for MIPS R-type instructions)
One possible assignment Instruction Opcode Values of fields that augment opcode Add 000 000 Sub 000 001 Jr 000 010 And 000 011 Or 000 100 Getinput 000 101 Putoutput 000 110 Addi 001 000 Beq 001 001 Bne 001 010 Lw 001 011 Sw 001 100 Sl 001 101 J 010 No field Jal 011 No field Rfe 100 No field Slt 101 No field
16-bit immediate Opcode rd rs Function field
Opcode 9-bit immediate
Fall 2005-2006 Computer Science and Software Engineering Profs. Archana Chidanandan and Larry Merkle Problem 4 [14 pts] Complete the MIPS program on the following pages by filling in the provided spaces with MIPS assembly language statements such that:
Assume the existence of another MIPS procedure product that returns in $v the product of its two integer parameters, which are passed in $a0 and $a1. In other words, even though product is not shown, you may call it, and you do not need to write it.
Read all the provided parts of the program, before you begin.
Fall 2005-2006 Computer Science and Software Engineering Profs. Archana Chidanandan and Larry Merkle
dotProduct: addi $sp, $sp, -16 # Create space on the stack sw $ra, 0($sp) # Place values to be preserved sw $s0, 4($sp) # on the stack. sw $s1, 8($sp) sw $s2, 12($sp)
move $s0, $a0 # $s0 = address of x[ count ] move $s1, $a1 # $s1 = address of y[ count ] move $s2, $a2 # $s2 = size move $s3, $0 # count = 0 move $s4, $0 # sum = 0
loop: slt $t0, $s3, $s2 # if( count < size) beq $t0, $0, exit1 # continue lw $t1, 0($s0) # Read x[ count ] from memory lw $t2, 0($s1) # Read y[ count ] from memory
Fall 2005-2006 Computer Science and Software Engineering Profs. Archana Chidanandan and Larry Merkle
.data x: .word 0 1 2 3 4 5 6 7 8 9 y: .word 1 2 3 4 5 6 7 8 9 10 N: .word 10 Msg: .asciiz "The dot product is”