[prev] 17 [next]

MIPS Assembly Language

Example MIPS assembler program:

# hello.s ... print "Hello MIPS"
# Equivalent to a C program that calls:
# printf("Hello MIPS\n");

       .data          # the data segment
msg:   .asciiz "Hello MIPS\n"

       .text          # the code segment
       .globl main
main:
        la $a0, msg   # load the argument string
        li $v0, 4     # load the system call (print)
        syscall       # print the string
        li  $v0,0     # set return value for main to be 0
        jr  $ra       # return from main to (__start)


Color coding: label, directive, comment