Question

What are the machine codes for the following MIPS assembly codes?                a. sub   $t0, $s0,...

What are the machine codes for the following MIPS assembly codes?

               a. sub   $t0, $s0, $s1

               b. lw       $t0, 20($s0)

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

a) For above compiled MIPS C code will be as follows

  • a = b - c;
  • a will be stored in $t0, b in $s0, c in $s1

Compiled MIPS code is

  • sub $t0, $s0, $s1
  • where the result of substration is stored in $t0

b) C code for above MIPS code is

  • a = A[5];
  • index 5 requires offset of 20 the value of A[5] will be loaded in variable a.
Add a comment
Know the answer?
Add Answer to:
What are the machine codes for the following MIPS assembly codes?                a. sub   $t0, $s0,...
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
  • 1.Please use 5-stage pipeline to describe following MIPS assembly code in non-forwarding pipeline. lw         $s0,      0($t0)...

    1.Please use 5-stage pipeline to describe following MIPS assembly code in non-forwarding pipeline. lw         $s0,      0($t0) add        $s1,      $s0, $s0 mul       $s2,      $s1, $s0 . 2.Please use 5-stage pipeline to describe following MIPS assembly code in forwarding pipeline. lw         $s0,      0($t0) add        $s1,      $s0, $s0 mul       $s2,      $s1, $s0 sw         $s2,      4($t0)

  • 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...

  • 2.4 For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the...

    2.4 For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively. sll $t0, $s0, 2               # $t0 = f * 4 add $t0, $s6, $t0         # $t0 = &A[f] sll $t1, $s1, 2               # $t1 =...

  • MIPS assembly language question If $s0 has the base address of array A, and A has...

    MIPS assembly language question If $s0 has the base address of array A, and A has the following elements: 9, 6, 4, 24, 33, 0, 1; What is the value of $t1 after the instructions are executed? addi $t1, $zero, 20 add $t0, $t1, $S0 lw $t1, (Sto)

  • The following MIPS assembly code contains a mistake that violates the MIPS convention in terms of...

    The following MIPS assembly code contains a mistake that violates the MIPS convention in terms of using stack for storing/protecting registers. What is the mistake and how should it be fixed? Correct the corresponding lines in the code. For the corrected code, sketch the stack frame contents at the time when the instruction ‘move $s1, $a1’ is being executed. f:   addi $sp, $sp, 12 sw   $ra, 8($sp) sw   $s1, 4($sp) sw   $s0, 0($sp) move $s0, $a0 move $s1, $a1              #...

  • PLEASE WRITE CLEARLY AND SHOW ALL STEPS SO THAT I CAN UNDERSTAND IT. THANKS Convert the...

    PLEASE WRITE CLEARLY AND SHOW ALL STEPS SO THAT I CAN UNDERSTAND IT. THANKS Convert the following MIPS assembly code into machine language. Write the machine code in hexadecimal. add $t0, $s0, $s1 lw $t0, -10($t1) addi $s1, $0, -20

  • Compiling C Programs into MIPS Assembly and Machine Code sll $t1, $a1, 2 add $t1, $a0....

    Compiling C Programs into MIPS Assembly and Machine Code sll $t1, $a1, 2 add $t1, $a0. $t1 lw $t0, 0($t1) lw $t2, 4($t1) sw $t2, 0($t1) sw $t0, 4($t1) 1. From the assembly code, what machine code might a MIPS assembler produce? 2. What does this program do? Write the C code for this assembly program.

  • Convert the following instructions from MIPS assembly language to machine language add $50, $t0, $s3 (op...

    Convert the following instructions from MIPS assembly language to machine language add $50, $t0, $s3 (op code: 0, function code: 32) sub $t9, $50, $zero (op code: 0, function code: 34) addi $s2, $t0, 16 (op code: 8, function code: Does not exist for I-type instructions)

  • Please answer all the questions! Thank you. For the following C statement, what would be the corresponding MIPS assembly...

    Please answer all the questions! Thank you. For the following C statement, what would be the corresponding MIPS assembly code? Assume that the variables a, b, c, and d are given and were declared as 32-bit integers a - b - (c + 7)+ d; 1. 2. Show how the value 0xB47CA034 would be arranged in a little-endian and big-endian machine Assume the data is being stored starting with address 0 3. Convert the following base-16 numbers to base-2 a....

  • Assume that registers $s0 and $s1 hold the values 8000000016 and D000000016, respectively.

    Assume that registers $s0 and $s1 hold the values 8000000016 and D000000016, respectively. a. What is the value of $t0 for the following assembly code? add $t0, $s0, $s1b. Is the result in $t0 the desired result, or has there been overflow?c. For the contents of registers $s0 and $s1 as specified above, what is the values of $t0 for the following assembly code? sub $t0, $s0, $s1d. Is the result in $t0 the desired result, or has there been...

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