Question

In: Computer Science

For the following MIPS instructions, (1) show its format or type (I-format, R- format, or J-...

For the following MIPS instructions, (1) show its format or type (I-format, R- format, or J- format); (2) translate them into binary using the follow procedure (Note: $s0-$s7 are the 16-23th registers, $t0-$t7 are the 8-15th registers). For example,

addi    $s0, $s1, 2               # the op code of addi is 0010002

Format (?):

lw       $s1, 4($s1)               # the op code of lw is 1000112

Format (?):

bne     $s1, $t1, loop           # the value of loop here is 00102 and

# the op code of bne is 0001012

Format (?):

jal       leaf                           # the value of leaf here is 0x2000016

                                 # the op code of jal is 0000112

Format (?):

sub     $t1, $s6, $0   # the op code of add is 0 and the funct code is 1000102      

Format (?):

Solutions

Expert Solution

addi    $s0, $s1, 2             
I-format

ADDI         $s1         $s0              immediate
001000   10001   10000   0000000000000010

Binary = 00100010001100000000000000000010
---------------------------------------------------------------------------------
lw       $s1, 4($s1)    
I-Format

LW           $s1          $s1                offset
100011   10001   10001   0000000000000100

Binary = 10001110001100010000000000000100
---------------------------------------------------------------------------------
bne     $s1, $t1, loop
I-Format:
BNE           $s1         $t1      offset
000101   10001   01001   0000000000000010

Binary = 00010110001010010000000000000010
---------------------------------------------------------------------------------
jal leaf                     
0x20000 >> 2 = 0x01000                      
J-Format
JAL                         target
000011   00000000000001000000000000

Binary : 00001100000000000001000000000000
---------------------------------------------------------------------------------
sub     $t1, $s6, $0
R-type

opcode   $s6      $zero   $t1        shamt   SUB
000000   10110   00000   01001   00000   100010

Binary: 00000010110000000100100000100010


Related Solutions

What are these C Codes in MIPS? A[R[j]] = -645 -j /4 A[32] = R[9j] -...
What are these C Codes in MIPS? A[R[j]] = -645 -j /4 A[32] = R[9j] - 4j A base address -> s0 R base address -> s1 j -> t1
Compile the following C code to MIPS assembly. a. Assume that i and j are stored...
Compile the following C code to MIPS assembly. a. Assume that i and j are stored in register $s1 and $s2, respectively. i = i – 2 + j; b. Assume base address of Array B and the variable i are stored in registers $s3 and $s1, respectively. B[1] = (B[0] x 4) - I; Explain each step in detail! my professor has the following answer: 1) addi $t0, $s1, -2 add $s1, $$t0, $s2 2) lw $t0, 0 ($s3)...
Complete the following problems using R. PLEASE SHOW ANSWER IN R FORMAT and be sure to...
Complete the following problems using R. PLEASE SHOW ANSWER IN R FORMAT and be sure to turn in explanations and interpretations where appropriate. 2.A random sample of 15 values of PAR (photosynthetically active radiation) were taken at noon in a certain forest (in moles per meter2per second). Data are included in the assignment .xlsx file. Assume that PAR is approximately normally distributed with a known standard deviation of 40.71 moles/(m2s). a.What is the mean value observed for PAR? b.What is...
Show that R-1(a)R(a) = I, where I is the identity matrix and R(a) is the rotation matrix.
Show that R-1(a)R(a) = I, where I is the identity matrix and R(a) is the rotation matrix. This equation shows that the inverse coordinate transformation returns you to the original coordinate system.  
Convert the following to machine code and then back to MIPS instructions: 1) a. addi $s0,...
Convert the following to machine code and then back to MIPS instructions: 1) a. addi $s0, $zero, -15 b. slt $t0, $s0, $s1 c. beq $t0, $zero, LEEQ d. j GRT
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that...
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that meets the following requirements (NOTE: your program statements should follow the order of the requirements and each requirement should correspond to only one assembly instruction): Loads the hexadecimal equivalent of 23710 into register 13 using an immediate bitwise OR instruction Loads the hexadecimal equivalent of 183410 into register 17 using an immediate bitwise OR instruction Performs the bitwise AND operation on the operands stored...
For this assignment, you are required to write a MIPS program that reads its own instructions...
For this assignment, you are required to write a MIPS program that reads its own instructions and counts the number of occurrences of each type of instruction (R-type, I-type, or J-type). To accomplish this task, your program should execute the following steps: First, your program should load the address of its first instruction (0x400000) into a register, and initialize three separate instruction class counters to zero. Next, your program should enter a loop that reads each instruction from memory. For...
PART 1: Design a program (using only native MIPS instructions, no pseudo instructions) that will prompt...
PART 1: Design a program (using only native MIPS instructions, no pseudo instructions) that will prompt user to enter three decimal numbers. Each decimal number will not exceed six digits The program can't ask user how many digits will be entered. Both numbers must be stored in memory as NULL terminated strings. The first number must be stored at the memory address 0x10000000. The second number must be stored in the memory 0x10000008. The third number must be stored at...
3. Let S3 act on the set A={(i,j) : 1≤i,j≤3} by σ((i, j)) = (σ(i), σ(j))....
3. Let S3 act on the set A={(i,j) : 1≤i,j≤3} by σ((i, j)) = (σ(i), σ(j)). (a) Describe the orbits of this action. (b) Show this is a faithful action, i.e. that the permutation represen- tation φ:S3 →SA =S9 (c) For each σ ∈ S3, find the cycle decomposition of φ(σ) in S9.
1. If I is an ideal of the ring R, show how to make the quotient...
1. If I is an ideal of the ring R, show how to make the quotient ring R/I into a left R-module, and also show how to make R/I into a right R-module.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT