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

Free

90.2K

Verified Solution

Question

Programming

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

addi    $s0, $s1, 2              # theop code of addi is 0010002

Format (?):

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

Format (?):

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

# the op code of bne is0001012

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 is1000102      

Format (?):

Answer & Explanation Solved by verified expert
4.3 Ratings (704 Votes)

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


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students