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: 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

Short Answer

Expert verified

This is a I type instruction

MIPS: lw $2, 4[$1]

Binary: 100011 00001 00010 0000000000000100

Step by step solution

01

Determine op=0:

op=0, rs=3, rt=2, rd=3, shamt=0, funct=34

this is R-type instruction

opcode :
The opcode is the machinecode representation of the instruction mnemonic. Several related instructions can have the same opcode. The opcode field is 6 bits long (bit 26 to bit 31).

Determine rs=3, rt=2, rd=3

rs, rt, rd:
The numeric representations of the source registers and the destination register. These numbers correspond to the $X representation of a register, such as $0 or $31. Each of these fields is 5 bits long. (25 to 21, 20 to 16, and 15 to 11, respectively). Interestingly, rather than rs and rt being named r1 and r2 (for source register 1 and 2), the registers were named "rs" and "rt" because t comes after s in the alphabet. This was most likely done to reduce numerical confusion.

Determine shamt=0

Shift (shamt):
Used with the shift and rotate instructions, this is the amount by which the source operand rs is rotated/shifted. This field is 5 bits long (6 to 10).

Determine Funct=34

Funct
For instructions that share an opcode, the funct parameter contains the necessary control codes to differentiate the different instructions. 6 bits long (0 to 5).
Example: Opcode 0x00 accesses the ALU, and the funct selects which ALU function to use

02

Converting MIPS fields to Assembly language

op=0 ---------> represents Add function. As several related instructions can have the same opcode we will consider the function also.
Funct =34 ------> converting decimal 34 to hexadecimal 0x22 which represent "sub" function.

ultimately ,the function which has opcode '0' and function '0x22' is "sub" function.

finally, the assembly level instruction is

sub $3, $3, $2

(rd rs rt)

03

conversion to binary format

R Format:

Converting an R mnemonic into the equivalent binary machine code is performed in the following way:


opcode

rs

rt

rd

shift

funct

6 bits

5 bits

5 bits

5 bits

5 bits

6 bits

opcode of sub is '0' and six bit long - 000000
rd,rs,rt,shift are five bit long so,
rd = $3 = 00011
rs = $3 = 00011
rt = $2 = 00010
shift = 0 = 00000
function is also six bit long ,funct = 34 = 100010

Now, put all binary numbers in a single line in the order mentioned above in the table that is your binary conversion of MIPS fields given;

000000 00011 00010 00011 00000 100010 ------> 621822(hexadecimal value)

op=0x23, rs=1, rt=2, const=0x4

op=0x23 represent " load word" i.e., lw
rs=1 represents "$1"
rt=2 represents "$2"
const=0x4


This is a I type instruction

MIPS: lw $2, 4[$1]

Binary: 100011 00001 00010 0000000000000100

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

[5] Assume for a given processor the CPI of arithmetic instructions is 1, the CPI of load/store instructions is 10, and the CPI of branch instructions is 3.

Assume a program has the following instruction breakdowns: 500 million arithmetic instructions, 300 million load/store instructions, 100 million branch instructions.

2.46.1 [5] <§2.19> Suppose that new, more powerful arithmetic instructions are added to the instruction set. On average, through the use of these more powerful arithmetic instructions, we can reduce the number of arithmetic instructions needed to execute a program by 25%, and the cost of increasing the clock cycle time by only 10%. Is this a good design choice? Why?

2.46.2 [5] <§2.19> Suppose that we find a way to double the performance of arithmetic instructions. What is the overall speedup of our machine? What if we find a way to improve the performance of arithmetic instructions by 10 times?

Question [5] <§2.7> Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a, b, i, and j are in registers \(s0, \)s1, \(t0, and \)t1, respectively. Also, assume that register $s2 holds the base address of the array D.

for(i=0; i<a; i++)

for(j=0; j<b; j++)

D[4*j] = i + j;

Show how the value 0xabcdef12 would be arranged in memory of a little-endian and a big-endian machine. Assume the data is stored starting at address 0

Question: Consider the following code:

lbu \(t0, 0(\)t1)

sw \(t0, 0(t2)

Assume that the register \)t1 contains the address and the register \(t2 contains the address

. Note the MIPS architecture utilizes big-endian addressing. Assume that the data (in hexadecimal) at the address is . What value is stored at the address pointed to by register \)t2?

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