-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path17)Traccia mia 02 02 18 v2
160 lines (117 loc) · 4.12 KB
/
17)Traccia mia 02 02 18 v2
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
.data
msg1:.asciiz "Dammi il valore di arr["
msg2:.asciiz"]["
msg3:.asciiz "] : "
msg_spazio:.asciiz" "
msg_slash:.asciiz"\n"
msg4:.asciiz "Matrice Originale : \n"
msg5: .asciiz "\nMatrice Processata : \n"
.align 2
matrix:.space 36
.text
.globl main
main:
la $a0,matrix
jal riempi_matrix
li $v0,4
la $a0,msg4
syscall
la $a0,matrix
jal stampa_matrix
la $a0,matrix
jal matrix_processata
li $v0,4
la $a0,msg5
syscall
la $a0,matrix
jal stampa_matrix
li $v0,10
syscall
#######################################################
riempi_matrix:
move $t0,$a0
li $t1,0 #i
li $t2,0 #j
loop1:
beq $t2,3,avanza_i
li $v0,4
la $a0,msg1
syscall
li $v0,1
move $a0,$t1
syscall
li $v0,4
la $a0,msg2
syscall
li $v0,1
move $a0,$t2
syscall
li $v0,4
la $a0,msg3
syscall
li $v0,5
syscall
sw $v0,0($t0)
addi $t0,$t0,4
addi $t2,$t2,1
j loop1
avanza_i:
addi $t1,$t1,1
beq $t1,3,exit
li $t2,0
j loop1
exit :
jr $ra
#######################################################
stampa_matrix:
move $t0,$a0
li $t1,0
li $t2,0
li $t3,0
loop2:
beq $t3,9,exit2
beq $t2,3,jump_down
lw $t1,0($t0)
li $v0,1
move $a0,$t1
syscall
li $v0,4
la $a0,msg_spazio
syscall
addi $t0,$t0,4
addi $t2,$t2,1
addi $t3,$t3,1
j loop2
jump_down:
li $v0,4
la $a0,msg_slash
syscall
li $t2,0
j loop2
exit2:
jr $ra
#######################################################
matrix_processata :
move $t0,$a0 #matrix2
li $t1,0
la $t2,matrix
li $t4,0
loop3:
beq $t1,9,exit3
beq $t1,3,azzera_valore
beq $t1,6,azzera_valore
beq $t1,7,azzera_valore
lw $t3,0($t2)
sw $t3,0($t0)
addi $t0,$t0,4
addi $t2,$t2,4
addi $t1,$t1,1
j loop3
azzera_valore:
sw $t4,0($t0)
addi $t0,$t0,4
addi $t2,$t2,4
addi $t1,$t1,1
j loop3
exit3:
jr $ra