How to Convert Binary to MIPS

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
Binary data is a string of ones and zeros often referred to as "machine language."

Binary data is a series of ones and zeros. Computers read and write in binary. Each 1 or 0 is a called a bit. Eight bits equals 1 byte. Each byte of a computer's memory is assigned a unique address. This unique value can also be called a "pointer" to that area of memory. MIPS Assembly is a programming language that translates the instructions in the Assembly program to binary so that the computer can read and execute the commands. You can also translate binary data to MIPS Assembly instructions or code.

Advertisement

Step 1

Determine what action your MIPS program will execute. For example, "Add $t1, $t2, $t3" is the MIPS code to add the contents of registry 10 to registry 11 and store the result in registry 9. The "destination" is $t1, the "source" is $t2 and the "target" is $t3.

Advertisement

Video of the Day

Step 2

Get the binary for the encoding of the "add." The binary encoding for this add to be performed in MIPS is "0000 00ss ssst tttt dddd d000 0010 0000." The pointers involved in the addition are $9, $10, and $11. Therefore, the binary for the five "s" bits would be for register 9, represented in binary as "10001." The five bits for "t" would be for register 10, represented in binary as "10010." And the "d" bits are represented as "10011" for 11.

Advertisement

Step 3

Using this information, if you are giving the binary string "0000 0010 0011 0010 1001 1000 0010 0000", you can translate it back to MIPS using this same method. Based on the binary encoding of the add method in MIPS, you know the first six values are zero and the last 11 are "000 0010 0000."

Advertisement

Advertisement

Step 4

Begin with the seventh digit and count five bits. That value is the "source" registry, "10 001." The second string of five bits is the value of the "target" and the next five, the "destination." If registry 12 were being referenced as the "destination", the binary string would look like this: "0000 0010 0011 0010 1010 0000 0010 0000" where "1010 0" is the value for 12.

Video of the Day

Advertisement

Advertisement

references