aboutsummaryrefslogtreecommitdiffstats
path: root/lcc/x86/linux/tst/sort.sbk
blob: 25cc4d97e566488390777fb92da53750dba286f5 (plain)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
.data
.globl in
.align 4
.type in,@object
in:
.long 10
.long 32
.long -1
.long 567
.long 3
.long 18
.long 1
.long -51
.long 789
.long 0
.size in,40
.globl main
.text
.align 16
.type main,@function
main:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
subl $4,%esp
pushl $10
pushl $in
call sort
addl $8,%esp
movl $0,-4(%ebp)
jmp .LC5
.LC2:
movl -4(%ebp),%edi
pushl in(,%edi,4)
call putd
addl $4,%esp
pushl $10
call putchar
addl $4,%esp
.LC3:
incl -4(%ebp)
.LC5:
movl -4(%ebp),%edi
cmpl $10,%edi
jb .LC2
movl $0,%eax
.LC1:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf6:
.size main,.Lf6-main
.globl putd
.align 16
.type putd,@function
putd:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
cmpl $0,20(%ebp)
jge .LC8
pushl $45
call putchar
addl $4,%esp
negl 20(%ebp)
.LC8:
movl 20(%ebp),%eax
movl $10,%ecx
cdq
idivl %ecx
cmpl $0,%eax
je .LC10
movl 20(%ebp),%eax
movl $10,%ecx
cdq
idivl %ecx
pushl %eax
call putd
addl $4,%esp
.LC10:
movl 20(%ebp),%eax
movl $10,%ecx
cdq
idivl %ecx
leal 48(%edx),%edi
pushl %edi
call putchar
addl $4,%esp
movl $0,%eax
.LC7:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf12:
.size putd,.Lf12-putd
.globl sort
.align 16
.type sort,@function
sort:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
movl 24(%ebp),%edi
subl $1,%edi
movl %edi,24(%ebp)
pushl %edi
pushl $0
movl 20(%ebp),%edi
movl %edi,xx
pushl %edi
call quick
addl $12,%esp
movl $0,%eax
.LC13:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf14:
.size sort,.Lf14-sort
.globl quick
.align 16
.type quick,@function
quick:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
subl $4,%esp
movl 28(%ebp),%edi
cmpl %edi,24(%ebp)
jl .LC16
jmp .LC15
.LC16:
pushl 28(%ebp)
pushl 24(%ebp)
pushl 20(%ebp)
call partition
addl $12,%esp
movl %eax,-4(%ebp)
movl -4(%ebp),%edi
subl $1,%edi
pushl %edi
pushl 24(%ebp)
pushl 20(%ebp)
call quick
addl $12,%esp
pushl 28(%ebp)
movl -4(%ebp),%edi
leal 1(%edi),%edi
pushl %edi
pushl 20(%ebp)
call quick
addl $12,%esp
movl $0,%eax
.LC15:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf18:
.size quick,.Lf18-quick
.globl partition
.align 16
.type partition,@function
partition:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
subl $8,%esp
incl 28(%ebp)
movl 24(%ebp),%edi
movl %edi,-8(%ebp)
movl -8(%ebp),%edi
movl 20(%ebp),%esi
movl (%esi,%edi,4),%edi
movl %edi,-4(%ebp)
jmp .LC21
.LC20:
incl 24(%ebp)
jmp .LC24
.LC23:
incl 24(%ebp)
.LC24:
movl 24(%ebp),%edi
movl 20(%ebp),%esi
movl -4(%ebp),%ebx
cmpl %ebx,(%esi,%edi,4)
jl .LC23
decl 28(%ebp)
jmp .LC27
.LC26:
decl 28(%ebp)
.LC27:
movl 28(%ebp),%edi
movl 20(%ebp),%esi
movl -4(%ebp),%ebx
cmpl %ebx,(%esi,%edi,4)
jg .LC26
movl 28(%ebp),%edi
cmpl %edi,24(%ebp)
jge .LC29
movl 20(%ebp),%edi
movl 28(%ebp),%esi
leal (%edi,%esi,4),%esi
pushl %esi
movl 24(%ebp),%esi
leal (%edi,%esi,4),%edi
pushl %edi
call exchange
addl $8,%esp
.LC29:
.LC21:
movl 28(%ebp),%edi
cmpl %edi,24(%ebp)
jl .LC20
movl 20(%ebp),%edi
movl 28(%ebp),%esi
leal (%edi,%esi,4),%esi
pushl %esi
movl -8(%ebp),%esi
leal (%edi,%esi,4),%edi
pushl %edi
call exchange
addl $8,%esp
movl 28(%ebp),%eax
.LC19:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf31:
.size partition,.Lf31-partition
.globl exchange
.align 16
.type exchange,@function
exchange:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl %esp,%ebp
subl $4,%esp
movl xx,%edi
movl $4,%esi
movl 24(%ebp),%ebx
subl %edi,%ebx
movl %ebx,%eax
movl %esi,%ecx
cdq
idivl %ecx
pushl %eax
movl 20(%ebp),%ebx
subl %edi,%ebx
movl %ebx,%eax
movl %esi,%ecx
cdq
idivl %ecx
pushl %eax
pushl $.LC33
call printf
addl $12,%esp
movl 20(%ebp),%edi
movl (,%edi),%esi
movl %esi,-4(%ebp)
movl 24(%ebp),%esi
movl (,%esi),%esi
movl %esi,(,%edi)
movl 24(%ebp),%edi
movl -4(%ebp),%esi
movl %esi,(,%edi)
movl $0,%eax
.LC32:
movl %ebp,%esp
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.Lf34:
.size exchange,.Lf34-exchange
.bss
.globl xx
.align 4
.type xx,@object
.size xx,4
.comm xx,4
.data
.align 1
.LC33:
.byte 101
.byte 120
.byte 99
.byte 104
.byte 97
.byte 110
.byte 103
.byte 101
.byte 40
.byte 37
.byte 100
.byte 44
.byte 37
.byte 100
.byte 41
.byte 10
.byte 0
.text
.ident "LCC: 4.1"