MIPS program that implements the same algorithm in C

(thanks for posting it). You appear to be using this definition of system calls (https://www.assemblylanguagetuts.com/mips-syscall-services-table/)

Just after the beq instruction in the while: loop, you increment $s1. I recall that MIPS cpus had a timing bug where it always executed the instruction following a branch. Here, that would mean that $s1 would be one more than you thought it would. The same applies to j while, but that is innocuous since it will be re-executed on loop exit.

The j outsidewhile seems a bit more sinister to me, because the opcode in the delay slot is a branch itself. Not sure how this resolves, but I wouldn’t tempt the gods here.

You need to add the code to print the strings, address and character, and probably an exit.
Beyond that, it looks ok; but you will have some debugging to do.

Browse More Popular Posts

Leave a Comment