	.data
a:	.word 4, 1, 12, 7, 9, 5, 7, 11, 9, 6
n:	.word 10

	.text
	
	lw $t3, n	# t3 = n
#	addi $t3, $t3, -1	# t3 = n - 1
	
repite:
	li $t0, 0	# cambios = 0 (false)
	li $t1, 1	# i = 1
	la $t2, a
	addi $t2, $t2, 4	# t2 apunta al segundo elemento
	
for:	beq $t1, $t3, final

	lw $s0, -4($t2)
	lw $s1, 0($t2)
	
	ble $s0, $s1, nocamb
	
	# intercambio
	sw $s0, 0($t2)
	sw $s1, -4($t2)
	li $t0, 1
	
nocamb:
	addi $t2, $t2, 4
	addi $t1, $t1, 1
	j for

final:
	beq $t0, 1, repite

	# stop
	li $v0, 10
	syscall
	