# Show the hex representation of MIPS instructions

1. ### shieldcy

5
Hey all
1. The problem statement, all variables and given/known data
Here i want to translate them and show the hex representation of these instructions:
1)add $t0,$t0, $zero 2)lw$t2, 16($s3) 2. Relevant equations 3. The attempt at a solution eg. 2) lw |$s3 | \$t2 | 16
I-TYPE

then translate the assembly code:
35 | 19 | 10 | 16

The solution is 0x8E6A0010
But i 've no idea how the answer has been reached... Any help?
Thank's a lot

Last edited: May 22, 2011

90
What is the context of this question? Should you be able to answer it on a test or is it a homework problem meant to familiarize you with your assembler? I would write the code, compile it, and view the answer by stepping through the code.

5
4. ### lewando

1,077
Looks like you have decomposed the assembly instruction correctly:

3510 = instruction
1910 = s
1010 = t
1610 = C

Convert the base-10 values that you obtained into binary. Then group your binary results into the following I-type format:
[iiiiiiss] [sssttttt] [CCCCCCCC] [CCCCCCCC]

(use 6-bits of your instruction result, 5-bits of s, 5 of t, 16 bits of C, zero-padding as needed)

Then convert each 8-bit group to its hexadecimal equivalent.

5. ### shieldcy

5
thank you so much! cheers ;)

6. ### shieldcy

5
Could you please show me the way to convert hex value 0x8E6A0010 to decimal?

Last edited: May 23, 2011

90
The nth digit corresponds to how many b^n's there are, starting at n = 0, where b is the base (16 here).

0*16^0 + 1*16^1 + 0*16^2 + ... + 8*16^7

8. ### shieldcy

5
Oo yeah... thank's man ;)