Debian Codegraph @

autotests/input/highlight.asm-mips

raw
1 # A demonstration of some simple MIPS instructions
2 # used to test QtSPIM
3
4 # Declare main as a global function
5 .globl main
6
7 # All program code is placed after the
8 # .text assembler directive
9 .text
10
11 # The label 'main' represents the starting point
12 main:
13 li $t2, 25 # Load immediate value (25)
14 lw $t3, value # Load the word stored in value (see bottom)
15 add $t4, $t2, $t3 # Add
16 sub $t5, $t2, $t3 # Subtract
17 sw $t5, Z #Store the answer in Z (declared at the bottom)
18
19 # Exit the program by means of a syscall.
20 # There are many syscalls - pick the desired one
21 # by placing its code in $v0. The code for exit is "10"
22 li $v0, 10 # Sets $v0 to "10" to select exit syscall
23 syscall # Exit
24
25 # All memory structures are placed after the
26 # .data assembler directive
27 .data
28
29 # The .word assembler directive reserves space
30 # in memory for a single 4-byte word (or multiple 4-byte words)
31 # and assigns that memory location an initial value
32 # (or a comma separated list of initial values)
33 value: .word 12
34 Z: .word 0