aboutsummaryrefslogtreecommitdiffstats
path: root/lcc/alpha/osf/tst/sort.sbk
blob: 4abc71b38925d9d288c2ee0b8c2fd51188abcf83 (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
.sdata
.globl in
.align 2
in:
.long 0xa
.long 0x20
.long 0xffffffff
.long 0x237
.long 0x3
.long 0x12
.long 0x1
.long 0xffffffcd
.long 0x315
.long 0x0
.globl main
.text
.text
.ent main
main:
ldgp $gp,0($27)
lda $sp,-80($sp)
.mask 0x4004000,-72
.frame $sp,80,$26,48
stq $14,0($sp)
stq $26,8($sp)
.prologue 1
lda $16,in
lda $17,10
jsr $26,sort
ldgp $gp,0($26)
mov $31,$14
br L.5
L.2:
sll $14,8*(8-4),$27
sra $27,8*(8-4),$27
sll $27,2,$27
ldl $16,in($27)
jsr $26,putd
ldgp $gp,0($26)
lda $16,10
jsr $26,putchar
ldgp $gp,0($26)
L.3:
lda $14,1($14)
L.5:
mov $14,$27
lda $25,10
cmpult $27,$25,$23
bne $23,L.2
mov $31,$0
L.1:
ldq $14,0($sp)
ldq $26,8($sp)
lda $sp,80($sp)
ret
.end main
.globl putd
.text
.ent putd
putd:
ldgp $gp,0($27)
lda $sp,-80($sp)
.mask 0x5004000,-64
.frame $sp,80,$26,48
stq $14,0($sp)
stq $24,8($sp)
stq $26,16($sp)
mov $16,$14
.prologue 1
cmplt $14,$31,$23
beq $23,L.7
lda $16,45
jsr $26,putchar
ldgp $gp,0($26)
negl $14,$14
L.7:
divl $14,10,$27
cmpeq $27,$31,$23
bne $23,L.9
divl $14,10,$16
jsr $26,putd
ldgp $gp,0($26)
L.9:
reml $14,10,$27
lda $16,48($27)
jsr $26,putchar
ldgp $gp,0($26)
mov $31,$0
L.6:
ldq $14,0($sp)
ldq $24,8($sp)
ldq $26,16($sp)
lda $sp,80($sp)
ret
.end putd
.globl sort
.text
.ent sort
sort:
ldgp $gp,0($27)
lda $sp,-64($sp)
.mask 0x4000000,-64
.frame $sp,64,$26,48
stq $26,0($sp)
stq $16,16($sp)
stq $17,24($sp)
.prologue 1
ldq $27,-48+64($sp)
stq $27,xx
mov $27,$16
mov $31,$17
ldl $27,-40+64($sp)
subl $27,1,$27
stl $27,-40+64($sp)
mov $27,$18
jsr $26,quick
ldgp $gp,0($26)
mov $31,$0
L.11:
ldq $26,0($sp)
lda $sp,64($sp)
ret
.end sort
.globl quick
.text
.ent quick
quick:
ldgp $gp,0($27)
lda $sp,-96($sp)
.mask 0x4007800,-64
.frame $sp,96,$26,48
stq $11,0($sp)
stq $12,8($sp)
stq $13,16($sp)
stq $14,24($sp)
stq $26,32($sp)
mov $16,$14
mov $17,$13
mov $18,$12
.prologue 1
cmplt $13,$12,$23
bne $23,L.13
br L.12
L.13:
mov $14,$16
mov $13,$17
mov $12,$18
jsr $26,partition
ldgp $gp,0($26)
mov $0,$11
mov $14,$16
mov $13,$17
subl $11,1,$18
jsr $26,quick
ldgp $gp,0($26)
mov $14,$16
lda $17,1($11)
mov $12,$18
jsr $26,quick
ldgp $gp,0($26)
mov $31,$0
L.12:
ldq $11,0($sp)
ldq $12,8($sp)
ldq $13,16($sp)
ldq $14,24($sp)
ldq $26,32($sp)
lda $sp,96($sp)
ret
.end quick
.globl partition
.text
.ent partition
partition:
ldgp $gp,0($27)
lda $sp,-112($sp)
.mask 0x4007c00,-72
.frame $sp,112,$26,48
stq $10,0($sp)
stq $11,8($sp)
stq $12,16($sp)
stq $13,24($sp)
stq $14,32($sp)
stq $26,40($sp)
mov $16,$14
mov $17,$13
mov $18,$12
.prologue 1
lda $12,1($12)
mov $13,$10
sll $10,8*(8-4),$27
sra $27,8*(8-4),$27
sll $27,2,$27
addq $27,$14,$27
ldl $11,($27)
br L.17
L.16:
lda $13,1($13)
br L.20
L.19:
lda $13,1($13)
L.20:
sll $13,8*(8-4),$27
sra $27,8*(8-4),$27
sll $27,2,$27
addq $27,$14,$27
ldl $27,($27)
cmplt $27,$11,$23
bne $23,L.19
subl $12,1,$12
br L.23
L.22:
subl $12,1,$12
L.23:
sll $12,8*(8-4),$27
sra $27,8*(8-4),$27
sll $27,2,$27
addq $27,$14,$27
ldl $27,($27)
cmple $27,$11,$23
beq $23,L.22
cmplt $13,$12,$23
beq $23,L.25
sll $13,8*(8-4),$27
sra $27,8*(8-4),$27
sll $27,2,$27
addq $27,$14,$16
sll $12,8*(8-4),$27
sra $27,8*(8-4),$27
sll $27,2,$27
addq $27,$14,$17
jsr $26,exchange
ldgp $gp,0($26)
L.25:
L.17:
cmplt $13,$12,$23
bne $23,L.16
sll $10,8*(8-4),$27
sra $27,8*(8-4),$27
sll $27,2,$27
addq $27,$14,$16
sll $12,8*(8-4),$27
sra $27,8*(8-4),$27
sll $27,2,$27
addq $27,$14,$17
jsr $26,exchange
ldgp $gp,0($26)
mov $12,$0
L.15:
ldq $10,0($sp)
ldq $11,8($sp)
ldq $12,16($sp)
ldq $13,24($sp)
ldq $14,32($sp)
ldq $26,40($sp)
lda $sp,112($sp)
ret
.end partition
.globl exchange
.text
.ent exchange
exchange:
ldgp $gp,0($27)
lda $sp,-112($sp)
.mask 0x5006000,-88
.frame $sp,112,$26,48
stq $13,0($sp)
stq $14,8($sp)
stq $24,16($sp)
stq $26,24($sp)
mov $16,$14
mov $17,$13
.prologue 1
lda $16,L.28
ldq $27,xx
stq $27,-80+112($sp)
mov $14,$25
subq $25,$27,$25
stq $25,-72+112($sp)
divq $25,4,$17
mov $13,$27
ldq $25,-80+112($sp)
subq $27,$25,$27
divq $27,4,$18
jsr $26,printf
ldgp $gp,0($26)
ldl $27,($14)
stl $27,-60+112($sp)
ldl $27,($13)
stl $27,($14)
ldl $27,-60+112($sp)
stl $27,($13)
mov $31,$0
L.27:
ldq $13,0($sp)
ldq $14,8($sp)
ldq $24,16($sp)
ldq $26,24($sp)
lda $sp,112($sp)
ret
.end exchange
.globl xx
.comm xx,8
.rdata
.align 0
L.28:
.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