Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Question: For each MIPS instruction, show the value of the opcode(OP), source register(RS), and target register(RT) fields. For the I-type instructions, show the value of the immediate field, and for the R-type instructions, show the value of the destination register(RD) field.

addi \(t0,\)s6,4

add \(t1.\)s6,\(0

sw \)t1, 0(\(t0)

lw \)t0,0(\(t0)

add \)s0,\(t1,\)t0

Short Answer

Expert verified

Instruction type,opcode, source and target for each instruction is given as follows:








Instructions

Type

OP

RS

RT

RD

immediate

addi $t0,$s6,4

I-type

8

22

8


4

add $t1,$s6, $0

R-type

0

22

0

9


sw $t1, 0($t0)

I-type

43

8

9


0

lw $t0, 0($t0)

I-type

35

8

8


0

add $s0,$t1,$t0

R-type

0

9

8

16


Step by step solution

01

Determine the MIPS instruction format types and Fields.

The MIPS instructions has the layout that is called the instruction format. There are two types of instructions R-type and I-Type.

R-type refers to the instructions that use registers for operations.

I-type refers to the instructions that use immediate value.

Fields of R-type is as follows:







OP

rs

rt

rd

shamt

function

Fields of I-type is as follows:





OP

rs

rt

Constant/address

02

Determine the MIPS Instruction type and fields of the given instruction

Given Instructions:

addi $t0,$s6,4

add $t1.$s6,$0

sw $t1, 0($t0)

lw $t0,0($t0)

add $s0,$t1,$t0

The instruction type and fields are as follows:

Instruction addi $t0,$s6,4:








Instructions

Type

OP

RS

RT

RD

immediate

addi $t0,$s6,4

I-type

8

22

8


4

The above instruction is I-type , since, it has immediate value of 4. The opcode of addi instruction is 8. The value of source register is 22 and the target register is 8. The immediate value 4 will be added to the value of source register and the result will be stored in target register.

Instruction :add $t1.$s6,$0








Instructions

Type

OP

RS

RT

RD

immediate

add $t1,$s6, $0

R-type

0

22

0

9


The above instruction is R-type , since the values are added by the registers. The value of opcode is 0 and the value of source register is 22. The value of destination register is 9.

Instructions:sw $t1, 0($t0)

lw $t0,0($t0)








Instructions

Type

OP

RS

RT

RD

immediate

sw $t1, 0($t0)

I-type

43

8

9


0

lw $t0, 0($t0)

I-type

35

8

8


0

Both the above instructions are I-Type , because they have immediate type addressing.

Sw instruction will store the data at the specified address with the possible offset, from a source register. The Opcode is 43 and the value of source and target registers are 8 and 9 respectively.

Lw instruction loads the word to the specified address. The Opcode is 35 and the value of source and target registers are 8 and 8 respectively.

Instruction: add $s0,$t1,$t0








Instructions

Type

OP

RS

RT

RD

immediate

add $s0,$t1,$t0

R-type

0

9

8

16


The above instruction is R-type , since the values are added by the registers. The value of opcode is 0 and the value of source register is 9. The value of target register is 8 and the destination register has 16.

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Question: Provide the type, assembly language instruction, and binary representation of instruction described by the following MIPS fields: op=0, rs=3, rt=2, rd=3, shamt=0, funct=34

The table below shows 32-bit values of an array stored in memory.

2.6.1 For the memory locations in the table above, write C code to sort the data from lowest to highest, placing the lowest value in the smallest memory location shown in the figure. Assume that the data shown represents the C variable called Array, which is an array of type int, and that the first number in the array shown is the first element in the array. Assume that this particular machine is a byte-addressable machine and a word consists of four bytes.

2.6.2 For the memory locations in the table above, write MIPS code to sort the data from lowest to highest, placing the lowest value in the smallest memory location. Use a minimum number of MIPS instructions. Assume the base address of Array is stored in register $s6.

Question: Write a program in MIPS assembly language to convert an ASCII number string containing positive and negative integer decimal strings, to an integer. Your program should expect register \(a0 to hold the address of a null-terminated string containing some combination of the digits 0 through 9. Your program should compute the integer value equivalent to this string of digits, then place the number in register \)v0. If a non-digit character appears anywhere in the string, your program should stop with the value -1 in register \(v0. For example, if register \)a0 points to a sequence of three bytes 50ten, 52ten, 0ten (the null-terminating string “24”), then when the program stops, register $v0 should contain the value 24ten .

Question: For the following C statement, what is the corresponding MIPS assembly code? 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.

Question: If the current value of the PC is 0x00000000, can you use a single jump instruction to get to the PC address as shown in Exercise 2.39?

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free