MIPS Assembly Language Programming Part 1

We start with a basic template for creating MIPS assembly language programming. Our target assembler is SPIM, available here for free. SPIM assembles and executes MIPS assembly language programs. It also provides some debugging tools. It does not require a MIPS hardware platform.

# File Name:
#  
# Author: nicomp
# Revision date: 
# References: 
# Starting Conditions / Assumptions:
#    What the registers should contain when the program begins...
#
# Ending Condition:
#    What the registers will contain when the program finishes...
#******************************************
#* Description:                           *
#*                                        *
#******************************************
.text 
.globl main 
main: 
#    Your code here



#    Graceful Exit
    li    $v0,10            # exit command for following syscall
    syscall 

.data
#your data here


Lines starting with # are comments, therefore the assembler ignores them. The majority of the template is comments. Like any assembly language, MIPS assembly language is notoriously not self-documenting, so we include several cues in the comments to remind you what's important. Don't be shy about adding more comments throughout the template. Imagine that you will have to revisit the program in a year; what would you want to know about it?

When creating a new program, don't start from scratch. Begin with the template, fill in the comments, then add your code following the main: label.

If you are writing a stand-alone program, leave the exit code in the template:

#   Graceful Exit
    li    $v0,10            # exit command for following syscall
    syscall


This code performs a system call that tells SPIM your program is finished.


More by this Author

  • The Importance of Doing Laundry
    19

    We could nag, but this is better. It is less work for us to use the words of others to emphasize the importance of doing laundry. Besides, if you saw the way we dressed, you'd laugh your mouse off.

  • Data Hiding in Java
    12

    Data Hiding is an aspect of Object Oriented Programming (OOP) that allows developers to protect private data and hide implementation details. In this tutorial we examine basic data hiding techniques in Java.

  • Introduction to Windows Notepad
    5

    A useful text editor is an essential component of any personal computer. Every day we need to make notes, compose documents, and record vital pieces of information. We depend on our text editor. Microsoft provided...


Comments 1 comment

nicomp profile image

nicomp 7 years ago from Ohio, USA Author

MIPS rocks

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working