Show the hex representation of MIPS instructions

In summary, the conversation provides steps on how to translate and show the hex representation of MIPS instructions. It also discusses converting hex values to decimal.
  • #1
shieldcy
5
0
Hey all

Homework Statement


Here i want to translate them and show the hex representation of these instructions:
1)add $t0, $t0, $zero
2)lw $t2, 16($s3)

Homework Equations


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:
Physics news on Phys.org
  • #2
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.
 
  • #4
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
thank you so much! cheers ;)
 
  • #6
Could you please show me the way to convert hex value 0x8E6A0010 to decimal?
 
Last edited:
  • #7
shieldcy said:
Could you please show me the way to convert hex value 0x8E6A0010 to decimal?

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
Oo yeah... thank's man ;)
 
  • #9
shieldcy said:
Oo yeah... thank's man ;)

No problem. That method works for converting any integer of any base into base 10 (you can even convert base 10 into base 10 with it).

e.g.
10110 base 2 = 0*2^0 + 1*2^1 + 1*2^2 + 0*2^3 + 1*2^4 = 2 + 4 + 16 = 22
 

1. How do I convert MIPS instructions into hexadecimal representation?

To convert MIPS instructions into hexadecimal representation, you can use an online converter or follow a series of steps. First, convert the MIPS instruction into binary code. Then, group the binary code into groups of 4 digits. Finally, use a binary to hexadecimal conversion chart to convert each group of 4 digits into a hexadecimal number.

2. What is the purpose of showing the hex representation of MIPS instructions?

The hex representation of MIPS instructions is used to make the instructions more readable and easier to interpret for humans. It also allows for a more compact representation of the instructions, making it easier to store and transfer them.

3. Are there any tools or software available to help with showing the hex representation of MIPS instructions?

Yes, there are numerous tools and software available that can convert MIPS instructions into their hexadecimal representation. Some popular options include online converters, IDEs such as Eclipse and Visual Studio, and command-line tools like MARS and SPIM.

4. Is the hex representation of MIPS instructions universal?

No, the hex representation of MIPS instructions can vary depending on the processor architecture and instruction set. It is important to use the correct conversion chart or tool for the specific architecture you are working with.

5. Can I use the hex representation of MIPS instructions to write code?

No, the hex representation of MIPS instructions is meant for human interpretation and is not a valid format for writing code. You should use assembly language or a high-level language to write MIPS instructions.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
14K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
5K
  • Programming and Computer Science
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
10K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
6K
  • Engineering and Comp Sci Homework Help
Replies
16
Views
10K
Back
Top