ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software

MIPS Assembly Language Programming Part 1

Updated on October 17, 2009

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.


Comments

    0 of 8192 characters used
    Post Comment

    • nicomp profile image
      Author

      nicomp really 7 years ago from Ohio, USA

      MIPS rocks

    Click to Rate This Article