Show the hex representation of MIPS instructions

Click For Summary

Discussion Overview

The discussion revolves around translating MIPS assembly instructions into their hexadecimal representation, specifically focusing on the instructions "add $t0, $t0, $zero" and "lw $t2, 16($s3)". The scope includes homework-related inquiries and technical explanations regarding the conversion process.

Discussion Character

  • Homework-related
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant presents a homework problem involving the translation of MIPS instructions into hexadecimal format and expresses uncertainty about the conversion process.
  • Another participant questions the context of the problem, asking whether it is for a test or for familiarization with the assembler, suggesting that compiling the code could provide the answer.
  • A later reply clarifies that the question is exam-related and that a MIPS assembly language table will be provided during exams.
  • One participant confirms the decomposition of the assembly instruction into base-10 values and suggests converting these values into binary, followed by grouping them into the I-type format for hexadecimal conversion.
  • Several participants request and provide explanations on how to convert the hexadecimal value 0x8E6A0010 into decimal, discussing the method of evaluating each digit based on its position and base.

Areas of Agreement / Disagreement

Participants generally agree on the method of converting assembly instructions to hexadecimal and the steps involved, but there is no consensus on the best approach to verify the results, as some suggest compiling the code while others focus on manual conversion methods.

Contextual Notes

Some participants express uncertainty about the conversion process and the context of the homework problem, indicating a reliance on provided resources and potential variations in understanding the conversion steps.

Who May Find This Useful

This discussion may be useful for students learning MIPS assembly language, those preparing for exams involving assembly code translation, and individuals interested in understanding the conversion between different numerical bases.

shieldcy
Messages
5
Reaction score
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
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.
 
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.
 
thank you so much! cheers ;)
 
Could you please show me the way to convert hex value 0x8E6A0010 to decimal?
 
Last edited:
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
 
Oo yeah... thank's man ;)
 
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
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
15K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
5
Views
11K
Replies
13
Views
39K