For the following code segment write the machine language representation of each instruction in binary. The instruction codes are add->32,beq->4,addi->8,      lw->35,j->2. Asume that Loop has the address of Ox4CB23             Loop:                        beq      $t1, $t2, done                        lw        $s1, 0(($t0)                        add      $s0, $s1, $s0                        addi     $t1, $t1, 1                        j           Loop            done:

Question
Asked Oct 8, 2019

 

  • For the following code segment write the machine language representation of each instruction in binary. The instruction codes are add->32,beq->4,addi->8,

      lw->35,j->2. Asume that Loop has the address of Ox4CB23

 

            Loop:

                        beq      $t1, $t2, done

                        lw        $s1, 0(($t0)

                        add      $s0, $s1, $s0

                        addi     $t1, $t1, 1

                        j           Loop

            done:

                       

check_circleExpert Solution
Step 1

Instruction 1:

beq Stl, St2, done
This instruction is I type
Format:
Орcode
Rs
Rt
offset
5bits
6bits
5bits
16bits
beq
Stl
St2
done
000100
01001
01010
0000000000000100
The offset for done is taken as 4 because it is the 4th instruction from lw instruction
beq St1, $t2, done
00010001001010100000000000000100
help_outline

Image Transcriptionclose

beq Stl, St2, done This instruction is I type Format: Орcode Rs Rt offset 5bits 6bits 5bits 16bits beq Stl St2 done 000100 01001 01010 0000000000000100 The offset for done is taken as 4 because it is the 4th instruction from lw instruction beq St1, $t2, done 00010001001010100000000000000100

fullscreen
Step 2

Instruction 2:

lw Ssl, 0(St0)
This instruction is also I type
Format:
Opcode
Rs
Rt
offset
5bits
6bits
5bits
16bits
beq
St0
$sl
0
100011
01000
10001
0000000000000000
lw $s1, 0(St0) - 10001101000100010000000000000000
help_outline

Image Transcriptionclose

lw Ssl, 0(St0) This instruction is also I type Format: Opcode Rs Rt offset 5bits 6bits 5bits 16bits beq St0 $sl 0 100011 01000 10001 0000000000000000 lw $s1, 0(St0) - 10001101000100010000000000000000

fullscreen
Step 3

Instruction 3:

...
add Ss0, Ssl, Ss0:
This instruction is R type:
Format:
Opcode
Rs
Rt
Rd
Sh
function
5bits
5bits
6bits
5bits
5bits
6bits
add
$s1
$s0
$s0
00000
100000
10000
000000
10001
10000
00000
100000
add Ss0, $s1, $s0
00000010001100001000000000100000
help_outline

Image Transcriptionclose

add Ss0, Ssl, Ss0: This instruction is R type: Format: Opcode Rs Rt Rd Sh function 5bits 5bits 6bits 5bits 5bits 6bits add $s1 $s0 $s0 00000 100000 10000 000000 10001 10000 00000 100000 add Ss0, $s1, $s0 00000010001100001000000000100000

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour*

See Solution
*Response times may vary by subject and question
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Question 4: What does the following code output? vector icecream ( 10, "Vanilla" ); icecream.insert...

A: The complete source code for the given question is given below along with the output.Note: If the he...

question_answer

Q: How do you make a Flowchart that makes change for $1 using quarters, dimes, and nickels?

A: Flowchart that makes change for $1 using quarters, dimes, and nickels

question_answer

Q: Hello good afternoon, This is my first time using Bartleby, I am super slow in computer science and ...

A: Program instructions:Declare necessary variables.Open the file with the score and total points and r...

question_answer

Q: In Python 3.7.4 Write a program that will compute the total cost of an amazon purchase. The program ...

A: ProgramSince two questions have been given and it is not clear the answer is sought for which questi...

question_answer

Q: PLEASE EXPLAIN ALL STEPSDevelop a k-map to simplify the equation (truth table included)

A:  Given boolean expression = xz + (xy + ~z)Now by using given truth table, draw a K-map of 8 cells by...

question_answer

Q: Use K-Maps to simplify each of the following: ~x~y~z + ~xyz + ~xy~z ~x~y~z + ~xy~z + x~y~z + xy~z ~...

A: Since there are 3 variables we construct the K-Map as follows and find the minimal cover of the map ...

question_answer

Q: Write a program in Java Eclipse that does the following:a) create a 2D Ragged array with columns and...

A: Create a Main class and all required methods to print Ragged array elements. And create all methods ...

question_answer

Q: C++ programming

A: Program Instructions:Use rand() function to initialize the array.Use two while loops to print the nu...

question_answer

Q: To keep track of students and their advisors, a university uses the table structure shown below. Ass...

A: Functional DependenciesThe set of functional dependencies based on the data is:Student _ID àStudent_...