SequentialSort S

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Ficheiro: /home/miguel/UA/AC2/P02/1/sequentialSort.

s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

.text
.globl sequentialSort
sequentialSort:
addiu $sp,$sp,-12
sw $ra,0($sp)
sw $s0,4($sp)
sw $s1,8($sp)
#
li $v0,0
#* n_trocas = 0
or $s0,$0,$a0
or $s1,$0,$a1
li $t2,0
#* i=0
outter_for:
addiu $t4,$s0,-1
bge
$t2,$t4,end
addiu $t3,$t2,1
#* j = i+1
inner_for:
bge
$t3,$s0,outter_for_incr
sll
$t5,$t2,2
#|
add
$a0,$t5,$s1 #|}-> array[i]
lw
$t5,0($a0) #|
#
sll
$t6,$t3,2
#|
add
$a1,$t6,$s1 #|}-> array[j]
lw
$t6,0($a1) #|
#
bge
$t6,$t5,inner_for_incr
jal
troca
addiu $v0,$v0,1
inner_for_incr:
addiu $t3,$t3,1
j inner_for
outter_for_incr:
addiu $t2,$t2,1
j outter_for
end:
#
lw $s1,8($sp)
lw $s0,4($sp)
lw $ra,0($sp)
addiu $sp,$sp,12
jr $ra

Pgina 1 de 1

You might also like