forked from Nilanshrajput/AC2MC-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.txt
72 lines (62 loc) · 1.16 KB
/
input.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
68
69
70
71
.data
var1: .word 12 10 13 7 4 22 19 11 23 8
.text
la x3, var1
addi x4, x0,9
jal x1,B_Sort
addi x5,x0,11
addi x6,x0,0
addi x7,x4,0
jal x1,B_Search
beq x0,x0,Exit
B_Search:
blt x7,x6,returnNotFound
add x8,x6,x7
srli x8,x8,1
slli x9,x8,2
add x9,x9,x3
lw x9,0(x9)
beq x5,x9,returnFound
addi sp,sp,-12
sw x1,8(sp)
sw x6,4(sp)
sw x7,0(sp)
blt x5,x9,SearchLeft
addi x6,x8,1
SearchLeft:
addi x7,x8,-1
jal x1,B_Search
lw x7,0(sp)
lw x6,4(sp)
lw x1,8(sp)
addi sp,sp,12
jalr x0,0(x1)
returnFound:
add x12,x0,x8
jalr x0,0(x1)
returnNotFound:
addi x12,x0,-1
jalr x0,0(x1)
B_Sort:
addi x5,x0,0
outerloop:
beq x5,x4,exit1
addi x6,x0,0
addi x7,x3,0
innerloop:
beq x6,x4,exit2
lw x8,0(x7)
lw x9,4(x7)
bge x9,x8,continue
sw x9,0(x7)
sw x8,4(x7)
continue:
addi x7,x7,4
addi x6,x6,1
beq x0,x0,innerloop
exit2:
addi x5,x5,1
beq x0,x0,outerloop
exit1:
jalr x0,0(x1)
Exit: