sorting array in mips (assembly)

This link explains how to print to the screen in a MIPS simulator like QTSPIM or MARS. As for the code, there were a few bugs. The line li $a0, 0 is overwriting the work done by the initial la $a0, Array instruction because the li is setting the base address of your array to 0. Instead, you should move the la instruction into the loop so … Read more

Difference between “addi” and “add” for pseudoinstruction “move” in MIPS?

The addi instruction requires an immediate operand rather than a register, so the $0 would actually be 0: Both will work and have all the needed information encoded into the instruction itself): However, it would be more usual to just use the zero-locked $0 register in this particular case since that is, after all, its purpose. I would also tend to use the unsigned variant however, since I … Read more

Arithmetic Overflow in mips

According to the MIPS instruction reference, the only addition operations which can produce overflow exceptions are the signed addition instructions: MIPS integers are 32-bit, and since you’ll be using signed integers, the maximum value is 231-1 (aka 2147483647 or hex 7FFFFFFF). Thus any addition which results in a number larger than this should throw an exception, … Read more