aboutsummaryrefslogtreecommitdiffstats
path: root/lcc/sparc/solaris/tst/sort.sbk
blob: 709dd460d4313917549dbb39d93e9f6cb20f4106 (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
.section ".data"
.global in
.type in,#object
.align 4
in:
.word 0xa
.word 0x20
.word 0xffffffff
.word 0x237
.word 0x3
.word 0x12
.word 0x1
.word 0xffffffcd
.word 0x315
.word 0x0
.size in,40
.global main
.section ".text"
.align 4
main:
save %sp,-96,%sp
set in,%o0
set 10,%o1
call sort; nop
mov %g0,%i5
ba .L5; nop
.L2:
sll %i5,2,%i4
set in,%i3
ld [%i4+%i3],%o0
call putd; nop
set 10,%o0
call putchar; nop
.L3:
add %i5,1,%i5
.L5:
mov %i5,%i4
set 10,%i3
cmp %i4,%i3; blu .L2; nop
mov %g0,%i0
.L1:
ret; restore
.type main,#function
.size main,.-main
.global putd
.align 4
putd:
save %sp,-96,%sp
cmp %i0,0; bge .L7; nop
set 45,%o0
call putchar; nop
neg %i0,%i0
.L7:
sra %i0,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i0,10,%i5
cmp %i5,0; be .L9; nop
sra %i0,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i0,10,%o0
call putd; nop
.L9:
sra %i0,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i0,10,%g1
; smul %g1,10,%g1; sub %i0,%g1,%i5
add %i5,48,%o0
call putchar; nop
mov %g0,%i0
.L6:
ret; restore
.type putd,#function
.size putd,.-putd
.global sort
.align 4
sort:
save %sp,-96,%sp
set xx,%i5
st %i0,[%i5]
mov %i0,%o0
mov %g0,%o1
sub %i1,1,%i5
mov %i5,%i1
mov %i5,%o2
call quick; nop
mov %g0,%i0
.L11:
ret; restore
.type sort,#function
.size sort,.-sort
.global quick
.align 4
quick:
save %sp,-96,%sp
cmp %i1,%i2; bl .L13; nop
ba .L12; nop
.L13:
mov %i0,%o0
mov %i1,%o1
mov %i2,%o2
call partition; nop
mov %o0,%i5
mov %i0,%o0
mov %i1,%o1
sub %i5,1,%o2
call quick; nop
mov %i0,%o0
add %i5,1,%o1
mov %i2,%o2
call quick; nop
mov %g0,%i0
.L12:
ret; restore
.type quick,#function
.size quick,.-quick
.global partition
.align 4
partition:
save %sp,-96,%sp
add %i2,1,%i2
mov %i1,%i4
sll %i4,2,%i3
ld [%i3+%i0],%i5
ba .L17; nop
.L16:
add %i1,1,%i1
ba .L20; nop
.L19:
add %i1,1,%i1
.L20:
sll %i1,2,%i3
ld [%i3+%i0],%i3
cmp %i3,%i5; bl .L19; nop
sub %i2,1,%i2
ba .L23; nop
.L22:
sub %i2,1,%i2
.L23:
sll %i2,2,%i3
ld [%i3+%i0],%i3
cmp %i3,%i5; bg .L22; nop
cmp %i1,%i2; bge .L25; nop
sll %i1,2,%i3
add %i3,%i0,%o0
sll %i2,2,%i3
add %i3,%i0,%o1
call exchange; nop
.L25:
.L17:
cmp %i1,%i2; bl .L16; nop
sll %i4,2,%i3
add %i3,%i0,%o0
sll %i2,2,%i3
add %i3,%i0,%o1
call exchange; nop
mov %i2,%i0
.L15:
ret; restore
.type partition,#function
.size partition,.-partition
.global exchange
.align 4
exchange:
save %sp,-96,%sp
set .L28,%o0
set xx,%i4
ld [%i4],%i4
mov %i0,%i3
sub %i3,%i4,%i3
sra %i3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i3,4,%o1
mov %i1,%i3
sub %i3,%i4,%i4
sra %i4,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i4,4,%o2
call printf; nop
ld [%i0],%i5
ld [%i1],%i4
st %i4,[%i0]
st %i5,[%i1]
mov %g0,%i0
.L27:
ret; restore
.type exchange,#function
.size exchange,.-exchange
.section ".bss"
.global xx
.type xx,#object
.size xx,4
.common xx,4,4
.section ".rodata"
.align 1
.L28:
.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