All pastes #758866 Raw Edit

Mine

public text v1 · immutable
·published 2007-11-02 17:21 UTC
rendered paste body
			la $a0, array		# load array address into $a

printArray:		addi $sp, $sp, -4	# make room on stack
			sw $a0, 0($sp)		# push $a0 onto the stack
							
			add $t0, $zero, $zero	# set loop counter to zero
			add $t1, $a0, $zero	# put array address in t1	

FOR_LOOP:		beq $t0, $a1, EXIT	# for loop equality check, $a1 is n parameter
			lw $a0, $t1
							
			li $v0, 1		# print the current int of the array
			syscall			#
						
			addi $t0, $t0, 1	# increment loop counter by 1
			addi $t1, $t0, 4	# advance to next array element
						
			j FOR_LOOP		# jump to beginning of loop (start new iteration)
							
EXIT:						# end of printArray's for loop
			lw $a0, 0($sp)		# pop $a0 off the stack
			addi $sp, $sp, 4	# "deallocate" stack memory
							
			jr $ra			# return control flow to main