# Add the first five integers
# C program:
#
# sum = 0;
# for (i=0; i<5; i++)
# sum = sum + i;
#
#
.text 0x0000 # Be sure to set memory configuration Compact, Text at 0
main:
add $8,$0,$0 # sum = 0
add $9,$0,$0 # for (i = 0; ...
loop:
add $8,$8,$9 # sum = sum + i;
addi $9,$9,1 # for (...; ...; i++
slti $10,$9,5 # for (...; i<5;
beq $10,$0,end
j loop
end:
j end # infinite loop "trap" because we don't have syscalls to exit