-
Notifications
You must be signed in to change notification settings - Fork 0
/
9.asm
90 lines (64 loc) · 934 Bytes
/
9.asm
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
.data
.space 30
mensagem1: .asciiz "Quantidade de valores a serem armazenados: "
mensagem2: .asciiz "Digite os valores a serem armazenados: "
mensagem3: .asciiz "Numero de pares: "
mensagem4: .asciiz "soma dos pares: "
.text
la $a0, mensagem1
li $v0, 4
syscall
li $v0, 5
syscall
move $t1, $v0
move $t3, $v0
la $a0, mensagem2
li $v0, 4
syscall
li $t2, 1
lui $a0, 0x1001
jal sub
sw $v0, ($a0)
addi $a0, $a0, 4
sub $t1, $t1, $t2
beqz $t1, cont
sub:
li $v0, 5
syscall
jr $ra
cont:
lui $a0, 0x1001
li $t6, 2
li $t2, 1
j iniciosub
soma:
add $s3, $s3, $t7
jr $ra
iniciosub:
jal sub2
add $s5, $s5, $t9
sub $t3, $t3, $t2
beqz $t3, fim
sub2:
lb $t7, ($a0)
div $t7, $t6
mfhi $t8
seq $t9, $t8, $zero
addi $a0, $a0, 4
beq $t9, $t2, soma
jr $ra
fim:
la $a0, mensagem3
li $v0, 4
syscall
move $a0, $s5
li $v0, 1
syscall
la $a0, mensagem4
li $v0, 4
syscall
move $a0, $s3
li $v0, 1
syscall
li $v0, 10
syscall