How to Translate Machine Code Instructions to MIPS Assembly?

  • Thread starter basketball853
  • Start date
  • Tags
    Binary Mips
In summary: You're welcome!In summary, the first six bits of the machine code instructions correspond to the add instruction, while the last six bits correspond to the shift instruction.
  • #1
basketball853
18
0

Homework Statement


Hey everybody! here is my question: Translate the following machine code instructions to MIPS assembly. What is the format of each instruction?
1. 0000 0000 0000 1010 0100 1010 1000 0000
2. 0000 0000 0010 0010 0010 0000 0010 0101

Homework Equations





The Attempt at a Solution


Now when trying to figure out the solution of the first, i looked into my book and found an opcode which was the same as the first 6. Which was add... now i figured out the format:
and got this as a result add $t1, $zero, $t2 is that right? i was unsure because i kinda felt like i left the last part out... i figured out 0000 00 | 00000| 0 1010| 01001|
but i didn't know if i had to do anything with the ending function --- 101 1000 0000 ?

also the second question i am having trouble figuring it out... i know that the opcode and the function match up to encode a certain type but when I am looking for both the opcode and function together in my book/online they only have the opcode? if this is the case then it is another add right?

Your help is appreciated!
 
Physics news on Phys.org
  • #2
I found 22 separate instructions that start with 000000. Go through those and find the one that matches the bits at the end.
 
  • #3
okay... so then is that a shift? I am looking at this website http://www.student.cs.uwaterloo.ca/~isg/res/mips/opcodes

of the last of the function am i just matching the last 6? which would be 000000? and the 5 before that would be the shamt (shift) amount?
 
  • #4
Looks like it to me - SLL (shift left logical) for the first one.
0000 00ss ssst tttt dddd dhhh hh00 0000

hhhhh is the shift amount
ttttt is the register whose value is shifted left
sssss is the register where the shifted result is stored
 
  • #5
okay cool, so i have:
OP = sll
$t2 = ttttt
$t1 = dddd
$t2 = h

sll $t1, $zero, $t2

would that be correct?
 
Last edited:
  • #6
Also along with the second one,
i figured it would be: or $a0, $at, $v0

Thank you for everything so far!
 

1. What is the purpose of converting binary to MIPS?

The purpose of converting binary to MIPS is to translate instructions written in binary (0s and 1s) into machine language that is readable and executable by a computer's central processing unit (CPU). This conversion allows the computer to understand and carry out the instructions given by the programmer.

2. How is binary translated into MIPS?

Binary is translated into MIPS by breaking down the binary instructions into smaller parts, such as the opcode and the operands. The opcode tells the computer what operation to perform, while the operands provide the necessary data for the operation. These parts are then converted into their corresponding MIPS instructions using a set of rules and conventions.

3. What are the benefits of using MIPS over binary?

MIPS is a higher-level language that is easier for humans to read and understand compared to binary, which is only understood by computers. This makes it easier for programmers to write and debug code. Additionally, MIPS allows for more complex operations and calculations to be performed using fewer lines of code than in binary.

4. Are there any limitations to converting binary to MIPS?

One limitation of converting binary to MIPS is that the instruction set must be supported by the computer's hardware. If the hardware does not have the necessary components to execute certain MIPS instructions, the conversion will not be successful. Additionally, converting binary to MIPS can be a time-consuming and tedious process, especially for complex programs.

5. Are there any tools or resources available to assist with converting binary to MIPS?

Yes, there are several tools and resources available to assist with converting binary to MIPS. These include MIPS assemblers and simulators, online converters, and textbooks or tutorials on assembly language programming. These resources can help with understanding the conversion process and identifying any errors in the translated code.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
7K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
13
Views
36K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
14K
Back
Top