-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path2.txt
67 lines (62 loc) · 1.23 KB
/
2.txt
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
.data
prompt: .asciiz "Enter n"
pri: .asciiz "Enter integer"
message: .asciiz "Largest is"
num: .word 0, 0
.text
main:
add $t2, $zero, $zero
li $v0, 4
la $a0, prompt
syscall
#getting the n value
li $v0, 5
syscall
#storing the result
add $t6, $v0, $zero
move $t0, $zero
la $s0, num
##
add $t2, $zero, $zero
##
loop:
mul $t4, $t2, 4
add $t1, $s0, $t4
#getting the user's numbers
li $v0, 4
la $a0, pri
syscall
#getting the value
li $v0, 5
syscall
add $t3, $v0, $zero
sw $t3, 0($t1)
addi $t2, $t2, 1
beq $t2, $t6, big
#printing
li $v0, 1
add $a0, $t3, $zero
syscall
j loop
big:
add $t2,$zero,$zero
lw $s4,0($s0)
add $t5, $zero, $s0 #Indexing
loop2:
beq $t2, $t6, end
lw $s5,0($t5)
slt $s6,$s5,$s4
beq $s6,1,else
add $s4,$s5,$zero
else:
addi $t2, $t2, 1
mul $t5,$t2,4
add $t5, $t5, $s0
j loop2
end:
li $v0, 4
la $a0, message
syscall
li $v0, 4
add $a0, $s4, $zero
syscall