forked from 996refuse/ASMBits-Solutions-ARMv7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path062 structsort.s
150 lines (144 loc) · 2.54 KB
/
062 structsort.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
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
// Some input data and testing code
.data
ProdList:
.word 0x1000, 10
.word 0x1001, 11
.word 0x1002, 9
.text
.global _start
_start:
ldr r0, =ProdList
ldr r1, =3
bl sort
1: b 1b // done
// Your function starts here:
sort:
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 24
@ frame_needed = 1, uses_anonymous_args = 0
@ link register save eliminated.
str fp, [sp, #-4]!
add fp, sp, #0
sub sp, sp, #28
str r0, [fp, #-24]
str r1, [fp, #-28]
mov r3, #0
str r3, [fp, #-8]
b .L2
.L7:
ldr r3, [fp, #-28]
sub r3, r3, #1
str r3, [fp, #-12]
b .L3
.L6:
ldr r3, [fp, #-12]
lsl r3, r3, #3
ldr r2, [fp, #-24]
add r3, r2, r3
ldr r2, [r3, #4]
ldr r3, [fp, #-12]
sub r3, r3, #-536870911
lsl r3, r3, #3
ldr r1, [fp, #-24]
add r3, r1, r3
ldr r3, [r3, #4]
cmp r2, r3
bgt .L4
ldr r3, [fp, #-12]
lsl r3, r3, #3
ldr r2, [fp, #-24]
add r3, r2, r3
ldr r2, [r3, #4]
ldr r3, [fp, #-12]
sub r3, r3, #-536870911
lsl r3, r3, #3
ldr r1, [fp, #-24]
add r3, r1, r3
ldr r3, [r3, #4]
cmp r2, r3
bne .L5
ldr r3, [fp, #-12]
lsl r3, r3, #3
ldr r2, [fp, #-24]
add r3, r2, r3
ldr r2, [r3]
ldr r3, [fp, #-12]
sub r3, r3, #-536870911
lsl r3, r3, #3
ldr r1, [fp, #-24]
add r3, r1, r3
ldr r3, [r3]
cmp r2, r3
bcs .L5
.L4:
ldr r3, [fp, #-12]
lsl r3, r3, #3
ldr r2, [fp, #-24]
add r3, r2, r3
ldr r3, [r3]
str r3, [fp, #-16]
ldr r3, [fp, #-12]
lsl r3, r3, #3
ldr r2, [fp, #-24]
add r3, r2, r3
ldr r3, [r3, #4]
str r3, [fp, #-20]
ldr r3, [fp, #-12]
sub r3, r3, #-536870911
lsl r3, r3, #3
ldr r2, [fp, #-24]
add r2, r2, r3
ldr r3, [fp, #-12]
lsl r3, r3, #3
ldr r1, [fp, #-24]
add r3, r1, r3
ldr r2, [r2]
str r2, [r3]
ldr r3, [fp, #-12]
sub r3, r3, #-536870911
lsl r3, r3, #3
ldr r2, [fp, #-24]
add r2, r2, r3
ldr r3, [fp, #-12]
lsl r3, r3, #3
ldr r1, [fp, #-24]
add r3, r1, r3
ldr r2, [r2, #4]
str r2, [r3, #4]
ldr r3, [fp, #-12]
sub r3, r3, #-536870911
lsl r3, r3, #3
ldr r2, [fp, #-24]
add r3, r2, r3
ldr r2, [fp, #-16]
str r2, [r3]
ldr r3, [fp, #-12]
sub r3, r3, #-536870911
lsl r3, r3, #3
ldr r2, [fp, #-24]
add r3, r2, r3
ldr r2, [fp, #-20]
str r2, [r3, #4]
.L5:
ldr r3, [fp, #-12]
sub r3, r3, #1
str r3, [fp, #-12]
.L3:
ldr r2, [fp, #-12]
ldr r3, [fp, #-8]
cmp r2, r3
bgt .L6
ldr r3, [fp, #-8]
add r3, r3, #1
str r3, [fp, #-8]
.L2:
ldr r3, [fp, #-8]
ldr r2, [fp, #-28]
cmp r2, r3
bhi .L7
nop
nop
add sp, fp, #0
@ sp needed
ldr fp, [sp], #4
bx lr