Skip to content

cmput229/MIPSPatterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MIPSPatterns

A resource for common coding structures in MIPS.

It's often difficult to translate high level programming structures that are often delimited by punctuation or indentation into the mostly syntax-free environment that is MIPS assembly. This resource aims to provide general patterns for beginning users to adapt for their needs as well as provide explanations that allow them to combine the different structures and eventually extend them to solve more subtle problems.

In this way, these files are meant to be suggestions or aids, not rules and laws. This is not the only way to solve your problems but it can help you get started.

Each file has two versions, one in explained/ and another in simplified/. The version in explained/ contains explanation and descriptions of why and how we do things as well as where things go and what things do. The version in simplified/ has nothing but the bare minimum of comments in an effort to distill the structure. Some of the explanations are rather long so the simplified files assume you already know why something might be done in a certain way.

The content is divided up as follows:

  1. Syntax and Structure: Discusses how a MIPS assembly file is structured.
    1. Labels and Sections: Introduces data/text section and labels within each.
    2. Data Section: Introduces common data section directives.
  2. Subroutines: Discusses how to interact with basic subroutines (leaf functions).
    1. Subroutines: Introduces basic leaf functions. More advanced functions use the stack.
    2. Main: Introduces what main should look like.
  3. Conditionals: Discusses how to form basic conditional statements.
    1. If: Introduces a basic if conditional.
    2. If/Else: Introduces an if with an unconditional else block.
    3. If/Elif/Else: Introduces an if with conditional elif blocks and finally an unconditional else block.
    4. Alternate If/Elif/Else: Shows a different style of conditionals that some may prefer.
  4. Loops: Discusses how to form basic loop statements.
    1. Precondition Loop: Introduces loops with a condition check before the body.
    2. Postcondition Loop: Introduces loops with an initial guard and then a condition check after the body.
  5. Complex Conditions: Discusses how to form composite conditions.
    1. And: Introduces a two-part condition joined by an and.
    2. Or: Introduces a two-part condition joined by an or.
  6. Stack: Discusses how to interact with the stack. This topic can be more difficult than previous sections.
    1. Saved Register Calling Convention: Introduces how to manage saved registers in a subroutine.
    2. Return Address Calling Convention: Introduces how to manage the return address register when a subroutine calls other subroutines.
    3. Temporary Register Calling Convention: Introduces how to manage temporary registers that are live across subroutine calls.
    4. Single Stack Unwind: Introduces a method to simplify subroutine code by using a single exit point.
  7. Kernel: Discusses how to act as the kernel. This topic can be more difficult than previous sections as well.
    1. Sections: Introduces the new sections used when acting as the kernel.
    2. __start: Introduces the __start label and how to use it.
    3. Register Saving: Introduces how to save registers in the kernel.

Contributors

  • Braedy Kuzma

About

A resource for common coding structures in MIPS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •