Some help with MIPS assembly code

In summary, the conversation involves someone seeking help with practicing basic MIPS programming. They are struggling to get the correct result using the given code, which involves plugging in values and following the provided instructions. The value of $t2 is needed but it is unclear what the code is intended to do. The code includes instructions for adding values to $t0, $t1, and $t2, as well as a "Bgtz" instruction and a "J" instruction.
  • #1
XodoX
203
0
Hey guys. I'm trying to practice some basic MIPS, but I can't seem to get this right. You just plug in the number and then you follow the code and you'll get obviously the end result. I can't get the result for these here. Does anybody know? I'd really appreciate help. Thank you!

1. $t0 = 0x55555555
$t1= 0x12345678

And $t2, $t0, $t1
Bgtz $t2, add 1
J end
Add0: addi $t0, $t0, 0
Add1: addi $t1, $t1, 1
Add2 : addi $t2, $t2, 2

End:


Value of $t2 is needed
 
Technology news on Phys.org
  • #2
What is this code supposed to do?

Not being familiar with MIPS programming I have a couple of questions:
1. What is the "1." doing in the first line?
2. Is it valid to have "add 1" in the Bgtz instruction?
 
  • #3
Just means #1 as in problem 1, sorry for the confusion.

And yes, it's valid. Just got to plug it in and get the value of t2.
 
  • #4
XodoX said:
Just means #1 as in problem 1, sorry for the confusion.

And yes, it's valid. Just got to plug it in and get the value of t2.
I don't understand. What do you mean "just got to plug it in and get the value of t2."

Also, what is this chunk of code intended to do?
Code:
$t0 = 0x55555555
$t1= 0x12345678

And $t2, $t0, $t1
Bgtz $t2, add 1
J end 
Add0: addi $t0, $t0, 0
Add1: addi $t1, $t1, 1
Add2 : addi $t2, $t2, 2

End:
 
  • #5
to complete the code and get the final result. Since $t2 is not initialized, the result cannot be calculated. The code is also missing a jump instruction to go back to the beginning of the loop. Additionally, the code is not clear on what the end goal is, making it difficult to provide a specific solution. It would be helpful to have more information on the desired outcome and the specific problem you are facing in order to provide a more accurate response. It may also be beneficial to consult online resources or seek guidance from a mentor or tutor for further assistance with MIPS assembly code.
 

Related to Some help with MIPS assembly code

1. What is MIPS assembly code?

MIPS assembly code is a low-level programming language used to write programs for MIPS-based processors. It stands for "Microprocessor without Interlocked Pipeline Stages" and is commonly used in embedded systems and other applications requiring high performance.

2. How is MIPS assembly code different from other programming languages?

MIPS assembly code is a low-level language, meaning it is closer to the machine code that the processor understands. This makes it more efficient and faster, but also more difficult to read and write compared to high-level languages like C or Java.

3. How can I learn MIPS assembly code?

Learning MIPS assembly code requires a basic understanding of computer architecture and binary operations. There are many online resources and tutorials available, as well as textbooks and courses that can guide you through the process.

4. Can MIPS assembly code be used for any type of program?

MIPS assembly code can be used to write programs for any application that runs on a MIPS-based processor, such as embedded systems, gaming consoles, and scientific instruments. However, it may not be the best choice for complex or large programs due to its low-level nature.

5. What are some common applications of MIPS assembly code?

MIPS assembly code is commonly used in embedded systems, such as routers, printers, and digital cameras. It is also used in gaming consoles like the PlayStation and scientific instruments like telescopes and microscopes.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Programming and Computer Science
Replies
1
Views
8K
  • Programming and Computer Science
Replies
4
Views
7K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Programming and Computer Science
Replies
4
Views
20K
  • Programming and Computer Science
Replies
1
Views
5K
Back
Top