.data
a: .space 12
i: .word 4
.space 70000
test: .byte 0
.text
.globl __start
# This segment shows the right and wrong ways to implement arrays in MIPS.
# It also illustrates a variety of pseudo instructions and how they are translated
# to real MIPS instructions
# a[3] = $5
__start: la $8, a
li $5, 20
sw $5, 12($8) # using 10 instead of 12 causes an error (misaligned memory)
# a[i] = $5
# works
lw $9, i
addu $8, $9, $8
sb $5, ($8)
# also works
lw $6, i
sb $5, a($6)
# doesnt work
la $6, a
sb $5, i($6) # note that the address i($6) becomes 0x2002000c which is an error
# the stuff below illustrates pseudo-instructions for branches
# mul instructions, and jump versus branch
lb $10, test
beq $4, $6, __start
mul $3, $4, $5
j end
# contrast with
# b end
end: li $v0, 10
syscall