Search code examples
mipssoftware-designmips32

Could you give me some guidance on how to efficiently design an assembly language program?


I'm a CS student at university, and I'm supposed to develop a MIPS assembly language program for an exam, but I do have a hard time designing it, especially when it comes to assigning registers, following calling conventions, saving registers on stack... It all seems to get pretty confusing and overwhelming rather fast, I lose track!

I don't have a problem figuring out, at least conceptually, an algorithm to solve a specific problem. It has more to do with the bigger picture, the overall structure and design of the project.

In light of this, could you point out a pattern, give tips or best practices to follow to sort everything out prior to actually writing code, so I don't lose myself in the process?


Solution

  • MIPS is a very unique language compared to other high level languages like Java OR Python, so it takes some time to get used to it. The way I would recommend about going with program development in MIPS is by doing the following:

    1. Make sure you understand and memorize each MIPS instruction that your professor has informed you about or that you know you will be tested on. Understand that MIPS has no if statements so you must create them all from scratch.
    2. Make sure you understand what data types each register can be loaded with, $t, $s etc.
    3. If you cannot do the first 2 steps, it will be near impossible to create an effective program in MIPS. So the next step is getting some scrap paper or a part of the exam where you can write on and start jotting down what you want your program to do, consider all the MIPS instructions you have and attempt to realize which instruction suits best for each task. Consider if you need to create any if statements or loops and use the appropriate branch or jump instruction. I truly believe it comes down to memorizing and truly understanding what each instruction does and which registers to accompany it with to develop good MIPS code.