# try removing all the comments and seeing just how short
# and concise the code really is. don't be afraid of array
# accesses.

.data
	# .word ensures that every value after it is aligned
	# (that is, their addresses are all multiples of 4)
	
	# it's up to the programmer to know how long the array
	# is, because the array isn't "a thing" to the CPU.
	arr: .word 5, 10, 15, 20, 25
	
	donemsg: .asciiz "\ndone.\n"
.text

# --------------------------------------------------
.global main
main:
	# s0 is being used as "i" in this loop.

	# my choice of s0 is kind of arbitrary, but I want
	# you to get used to using s registers as loop
	# counter variables.

	# for(i = 0; i < 5; i++)
	li s0, 0
	_loop:
		# print_int(arr[i])

		# first you have to multiply the index by the
		# byte size of one array item
		mul t0, s0, 4

		# then use that multiplied in the parens of
		# this second form of lw/sw.
		lw a0, arr(t0)
		li v0, 1
		syscall
		
		# print_char(' ') (a space)
		li a0, ' '
		li v0, 11
		syscall
	
	add s0, s0, 1 # <-- increment goes HERE!
	blt s0, 5, _loop # <-- the length here is hard-coded.
	# if you changed the length of the array, you'd need
	# to change the loop bound here.
	
	# print("\ndone.\n")
	la a0, donemsg
	li v0, 4
	syscall

	# exit!
	li v0, 10
	syscall