Mips Assembly

2 minute read


As part of my COMP360 Computer Architecture course that I am really enjoying we are learning some MIPS Assembly Language Programming. Assembly is one of those languages that you just have to know if your a computer geek like myself. Anyways, the latest assignment had us right some of our first real MIPS code. I was thrilled. It was Saturday afternoon and I flew right through it. I don’t think I even made a typo.

Then I got the bright idea to try it on the MIPS simulator running on Einstein - Franklin’s Computer Science machine to which I have access. Of course it didn’t work. But keep reading, it gets better. The part that didn’t work was something I just learned how to do - a “jal”. Basically a goto that remembers were it came from so you can “jr $ra” back to the right address. I properly loaded $a0 before the call, and properly saved the data into $v0 during the call. But it just wouldn’t work. I kept getting 88 when I should have had 1023. I tried replacing the jump with the instructions that were in the sub routine (we didn’t really need it, but it was the concept.) and that did work.

Why? What was different? What was I doing wrong? I couldn’t figure it out, I was pissed, and I went out for the night. Of course the way my mind works it stayed on my mind and ruined my fun.

Today was a new day. I knocked out all three of my other assignments for Franklin and got back into the assembly. I checked my code for errors, found none. Thought I found an error, but I didn’t. Read my book. Re-read my book. Looked on the Internet. All looked fine. But it didn’t work.

Then I remembered seeing xspim mentioned in the back of the book. Since I was in Debian I ran apt-get spim and fired it up. loaded my asm file. Marked a break point. Started execution. Hit the breakpoint…

You know what happened?

It worked.

The moral of this story? Jim is smarter than the MIPS Simulator on Einstien. Xspim is king, and I wasted hours of time debbugging something that wasn’t broken. If I ever figure out what the simulator is called (it’s a java app that says it’s based on spim) I’ll update this post so you can be sure you don’t pull your hair out with it.

As an Amazon Associate I earn from qualifying purchases.