Some help with MIPS assembly code

Click For Summary

Discussion Overview

The discussion revolves around a MIPS assembly code snippet that a participant is trying to understand and troubleshoot. The focus is on the functionality of the code and the expected output, particularly the value of the register $t2 after execution. The conversation includes questions about the code's structure and purpose.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant seeks help with MIPS code, specifically asking for the value of $t2 after executing the provided instructions.
  • Another participant questions the purpose of the "1." in the first line and the validity of the "add 1" in the Bgtz instruction.
  • A participant clarifies that "1." refers to problem number 1 and asserts that the instruction is valid, suggesting that the value of $t2 can be obtained by executing the code.
  • A further inquiry is made about the overall intention of the code and its expected behavior.

Areas of Agreement / Disagreement

Participants do not appear to reach a consensus on the intended functionality of the code or the specific output expected for $t2. Multiple viewpoints regarding the interpretation of the code and its instructions remain present.

Contextual Notes

There are uncertainties regarding the execution flow of the code and the specific operations performed on the registers, which may depend on the initial values and the interpretation of the instructions.

XodoX
Messages
195
Reaction score
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
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?
 
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.
 
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:
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
11K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 4 ·
Replies
4
Views
22K
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 2 ·
Replies
2
Views
5K