# A demonstration of some simple MIPS instructions # used to test QtSPIM # Declare main as a global function .globl main # All memory structures are placed after the # .data assembler directive .data # The .word assembler directive reserves space value: .word 12 msg: .asciiz "Hello CENG3420!\n" # All program code is placed after the # .text assembler directive # The label ’main’ represents the starting point .text main: li $t2, 25 # Load immediate value (25) lw $t3, value # Load the word stored at label ’value’ add $t4, $t2, $t3 # Add sub $t5, $t2, $t3 # Subtract la $a0, msg # Pointer to string li $v0, 4 # to use print_string syscall syscall # Exit the program by means of a syscall. # There are many syscalls - pick the desired one # by placing its code in $v0. The code for exit is "10" li $v0, 10 # Sets $v0 to "10" to select exit syscall syscall # Exit