cvut / QtMips

MIPS CPU emulator
https://github.com/cvut/QtMips
GNU General Public License v3.0
55 stars 12 forks source link

Code does not run correctly on QtMips #8

Closed andathan closed 4 years ago

andathan commented 4 years ago

Hello, i have found online on github two different codes about quicksort. I tried to test them on QtMips so I removed any incompatible syscalls, i placed the .data section under the .text section and I converted any pseudoinstructions. In both cases, the program (after these modifications) runs correctly on others simulators (for example MARS). However when I run them on QtMips it just gets in a non-ending loop of swapping number x with y and then y with x. Since the code is correct (because it runs on other simulators) what am I doing wrong?I have tried many different setups (cache/pipeline etc).

Are all MIPS instructions implemented with the same way as in other simulators? Are jumps (recursion) allowed?

Cynerd commented 4 years ago

Post of code causing this behavior would be appreciated. Thank you.

andathan commented 4 years ago

I am attaching the code in txt format. The same code produces correct results on MARS (correct = sorted array).

Disclaimer: The code origins from here. I just did the modifications described above.

quicksort.txt Thank you

andathan commented 4 years ago

Problem Solved after putting some NOP commands after all branch commands (j, jr, jal, beq, bne etc). Probably the simulator loaded the next command after the jump (in the delay slot) before executing it, thus changing the result of the program.