Process of Converting a MIPS Instruction to its Hex code

Captain Hook

I'm trying to find an explanation online, but everything I find seems to be a conversion program someone wrote that doesn't really explain it. Looked for questions here on SO and most of it is above my pay grade, I'm looking at the very beginning of the basics. I understand the idea (I think):

`add $s0, $s3, $s5`

Isolate them like so Green sheet snippet

And keeping in mind "rd" needs to come from the first register, $s0, convert the pieces to hex based on the MIPS Green Sheet, giving us

add = op code of 0  
$s3 = 19 in decimal, 13 in hex  
$s5 = 21 in decimal, 15 in hex  
$s0 = 16 in decimal, 10 in hex  
shamt = 0  
funct = 20 from add

This already has me lost, since it would be 0131510020... Not 8 bits. Nope.

And based on this online converter, it comes out as

`02758020` in hex

How in the world does that happen? I'm even playing with the converter, just moving up one register at a time and the changes are just confusing me further. Is there a trick to this I missed or a good resource? Every video I find is talking about machine code (binary) and never goes into the hex portion of it.

Dirbaio

You need to put it together in binary, not in hex.

The little numbers in the image tell you the amount of bits of every part.

add = op code of 0, 000000 in bin
$s3 = 19 in decimal, 13 in hex, 10011 in bin
$s5 = 21 in decimal, 15 in hex, 10101 in bin
$s0 = 16 in decimal, 10 in hex, 10000 in bin
shamt = 0, 00000 in bin
funct = 20 from add, 10100 in bin

Then put everything together and convert to hexadecimal:

0b00000010011101011000000000100000 = 0x02758020

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Process of Converting a MIPS Instruction to its Hex code

From Dev

How to represent mips instruction as it's hex representation

From Dev

MIPS what hex word encodes branch instruction?

From Dev

Converting C code to MIPS Assembly Language

From Dev

Converting C code to mips gives error

From Dev

Converting a hex string to its BigInteger equivalent negates the value

From Dev

Converting 2 chars to its ascii binary code

From Dev

Instruction Execution in MIPS

From Dev

MIPS Instruction Register

From Dev

MIPS register instruction decoding

From Dev

JUMP instruction in MIPS

From Dev

MIPS difference in this instruction?

From Dev

Find an instruction in an executable file, given its address in a running process?

From Dev

Find an instruction in an executable file, given its address in a running process?

From Dev

converting a C for loop to MIPS

From Dev

Converting C to MIPS

From Dev

Handling AnsiString and its Hex code in Unicode aware Delphi versions

From Dev

How to change to a specific color by its hex code in GIMP?

From Dev

Run a process, capture its output and exit code

From Dev

Run a process, capture its output and exit code

From Dev

ARM instruction to hex

From Dev

Does an instruction of sleep thread or process continues its execution while the thread/process is slept?

From Dev

MIPS: lw (load word) instruction

From Dev

Byte Manipulation for MIPS instruction set

From Dev

Mips datapath procedure for executing an AND instruction?

From Dev

MIPS I instruction immediate field

From Dev

Branch instructions and Jump instruction in Mips

From Dev

MIPS critical path of a branch instruction

From Dev

Is "muli" a MIPS instruction? Where is it defined?

Related Related

HotTag

Archive