Page 1 of 1
My Instructions
Posted: Fri Feb 13, 2009 7:11 pm
by MagneticMonopole
Should not the program end at the first break? From what I read about the MIPS branch opcodes, the instruction immediately following the branch instruction (in the so called delay slot) is always executed first, no matter if the branch takes place or not; the branching takes place only thereafter. (This peculiar behaviour is to be for performance reasons).
"If the contents of GPR rs and GPR rt are not equal, branch to the effective target address after the instruction in the delay slot is executed."
- MIPS32™ Architecture For Programmers Volume II, Revision 0.95, Page 76
Not a problem for the challenge, though, as "pip" was quickly rejected as an answer.
Posted: Sat Feb 14, 2009 9:25 am
by osterlaus
This seems to depend onto the disassembler you used. I also heard about unusable labels.
Posted: Sat Feb 14, 2009 9:52 am
by MagneticMonopole
Actually, I deciphered the opcodes manually. Never thought about a disassembler, which would indeed have been a nice aid. Anyway, the numbers representing the BREAKs are next to the BNEs with no instruction between...
What do you mean with unusable labels?
Posted: Sat Feb 14, 2009 10:13 am
by osterlaus
Hmmm, as I see, the program would not break at 0x15200001 as this line tests $9 (which is $t1, filled with 10 in the line above) against 0. If this is not equal, branch by one line - we've stepped over break.
Posted: Sat Feb 14, 2009 11:50 am
by gfoot
The point was that the branch actually doesn't happen until after the following instruction, in MIPS - it's nothing to do with the disassembler, it's a CPU feature. I don't know for sure - I've never written MIPS assembly - but it does ring a bell from PS2 days.
Posted: Sat Feb 14, 2009 2:50 pm
by osterlaus
Oh, yeah, now I got it - well, according to the solution of the challenge, this is a pipelining feature / problem called "Delayed branching" in MARS. I got it disabled, and so you are right. What do you think - should I give Adum a new version with delayed branches or should this be a nice trick in the challenge?
Posted: Wed May 01, 2013 10:53 am
by AlbusShin
Still don't understand what the branch means and deleted all the branches instructions worked for me...