Question

If I am given a MIPS assembly instruction and asked to write the corresponding machine code bit string representation how do

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

R-Type Instructions: These instructions are identified by an opcode of 0, and are differentiated by their funct values. Except for the first 3 shift instructions, these operations only use registers. Note that in addition to arithmetic operations, these instructions also include jumps and the system call instruction.

These instrutcions have:

  • rs: 1st register operand (register source) (5 bits)
  • rt: 2nd register operand (5 bits)
  • rd: register destination (5 bits)
  • shamt: shift amount (0 when N/A) (5 bits)
  • funct: function code (identifies the specific R-format instruction) (6 bits)

Example:

add $s0, $s1, $s2

J-Type Instructions: These instructions are identified and differentiated by their opcode numbers (2 and 3). Jump instructions use pseudo-absolute addressing, in which the upper 4 bits of the computed address are taken relatively from the program counter.

Example:

j Loop

I-Type Instructions: These instructions are identified and differentiated by their opcode numbers (any number greater than 3). All of these instructions feature a 16-bit immediate, which is sign-extended to a 32-bit value in every instruction (except for the and, or, and xor instructions which zero-extend and the lui instruction in which it does not matter). Branch instructions also effectively multiply the immediate by 4, to get a byte offset.

These instructions have:

  • rs: register containing base address (5 bits)
  • rt: register destination/source (5 bits)
  • immediate: value or offset (16 bits)

Example:

lw $t0, 32($s3)

Please give thumbsup, if you like it. Thanks.

Add a comment
Know the answer?
Add Answer to:
If I am given a MIPS assembly instruction and asked to write the corresponding machine code...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT