1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Converting Binary to Mips

  1. Feb 1, 2011 #1
    1. The problem statement, all variables and given/known data
    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

    2. Relevant equations

    3. 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 im 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!
    1. The problem statement, all variables and given/known data

    2. Relevant equations

    3. The attempt at a solution
  2. jcsd
  3. Feb 1, 2011 #2


    Staff: Mentor

    I found 22 separate instructions that start with 000000. Go through those and find the one that matches the bits at the end.
  4. Feb 1, 2011 #3
    okay... so then is that a shift? im 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?
  5. Feb 1, 2011 #4


    Staff: Mentor

    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
  6. Feb 1, 2011 #5
    okay cool, so i have:
    OP = sll
    $t2 = ttttt
    $t1 = dddd
    $t2 = h

    sll $t1, $zero, $t2

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

    Thank you for everything so far!
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Converting Binary to Mips