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
  • B2. Translate the following MIPS assembly instruction into machine language: lw $t8, 100($s0) B3 ...

    B2. Translate the following MIPS assembly instruction into machine language: lw $t8, 100($s0) B3 Write MIPS assembly code segment for the following C code snippet: for (i - O i < 10i i++) i array[i+l] - array [i8; Register assignment: i-> Şa0 Base of array -> $s0 B2. Translate the following MIPS assembly instruction into machine language: lw $t8, 100($s0) B3 Write MIPS assembly code segment for the following C code snippet: for (i - O i Şa0 Base of...

  • For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables...

    For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables f, g, h, and i are given and could be considered 32-bit integers as declared in a C program. Use a minimal number of MIPS assembly instructions: f g(h 5); For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables f, g, h, and i are given and could be considered 32-bit integers as declared in a C...

  • Question 3 (10 points) Convert the following MIPS assembly code into machine language. Write the instruction...

    Question 3 (10 points) Convert the following MIPS assembly code into machine language. Write the instruction in hexadecimal. The opcode for sw 43 (101011). sw St1, -4(St3) Question 4 (10 points) Consider the following MIPS assembly code: addi $s3, $0, 5 addi $s1, S0, 3 addi Ss1, $s1, 2 beq Ss3, Ssl, target addi Ss1, Ss1, 1 target: add Ss3, Ss1, Ssl a. After running the code, what is the value of Ss3? b. If the memory address of the...

  • Should be written in Python: A disassembler takes a machine code file (binary) and converts it...

    Should be written in Python: A disassembler takes a machine code file (binary) and converts it back into assembly code. Disassemblers are a key tool in the software reverse engineering process because it allows you to go from the raw binary all the way back to the original source code, if desired. For this assignment you will be given 8 32-bit binary strings and the type of the instruction (I-type, R-type, or J-type). You’ll write a basic disassembler in Python...

  • 1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume...

    1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume f, g, h correspond to $80, $s1, and $s2, respectively. f=g+(h-5) 2. (15 pts) For the following pseudo-MIPS assembly instructions, what is the corresponding C code? add f, g, h add f,i, f 3. (30 pts) Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the following MIPS fields: a. op = 0, rs = 18, rt=9, rd...

  • Problem #2 (20pts) Please write the MIPS assembly code corresponding to the following C code segment....

    Problem #2 (20pts) Please write the MIPS assembly code corresponding to the following C code segment. Assume that f is assigned to register $s2 int Example int i, int j, int k) int f; f i+j-k-1: return fi

  • For the following C statement, what is the corresponding MIPS assembly code? Assume the arrays hold...

    For the following C statement, what is the corresponding MIPS assembly code? Assume the arrays hold 16-bit integer values, $ s0 is the base for array X, $ s1 is the base for array Y, and $ t0 and $ t1 are index variables i and j respectively. Comment code X [j] = Y [i + j];

  • Please answer the following questions involving MIPS assembly code: A) For the C statement below, what...

    Please answer the following questions involving MIPS assembly code: A) For the C statement below, what is the corresponding MIPS assembly code? Assume f, g are stored in S1 and S2. f = g + (-f -5) B) For the C statement below, what is the corresponding MIPS assembly code? Assume i and j are assigned in registers S1 and S2 respectively and base of address of arrays A and B are in registers S6 and S7. B[8] = A[i...

  • 5. a. Given the following MIPS instructions with their corresponding addresses, answer the following questions. Address...

    5. a. Given the following MIPS instructions with their corresponding addresses, answer the following questions. Address 1000 Instruction sll St1, $s2, 4 1w $t0, 128(Stl) bne Sto, $15, Exit j Here Start: 1004 Here: 1008 1012 Exit: 1096 i. Write the machine code for each of the above MIPS instructions (5 pts) ii. Find the total number of bits required to store the instructions (3 pts) 5. a. Given the following MIPS instructions with their corresponding addresses, answer the following...

  • Please Help Using Mips Assembly How can i reverse a 32-bit sequence? Proper instruction and code...

    Please Help Using Mips Assembly How can i reverse a 32-bit sequence? Proper instruction and code are appreciated .data testcase1:    .word   0x00200020 # reverse is 0x04000400 testcase2:    .word    0x00300020 # reverse is 0x04000c00    testcase3:    .word   0x1234fedc # reverse is 0x3b7f2c48

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