annotate lab4/test/queens2.p @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
rev   line source
0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
1 (* N queens with array of choices *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3 const N = 8;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5 proc queens(k: integer; var choice: array N of integer);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 var y, j, q: integer; ok: boolean;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 if k = N then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 print(choice)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 else
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11 y := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 while y < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 j := 0; ok := true;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 while ok and (j < k) do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 q := choice[j];
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 ok := (q <> y) and (q+j <> y+k) and (q-j <> y-k);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 j := j+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 if ok then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20 choice[k] := y;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 queens(k+1, choice)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 y := y+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24 end
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25 end
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
28 proc print(var choice: array N of integer);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
29 var x: integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
30 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
31 x := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
32 while x < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
33 print_num(choice[x]+1);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
34 x := x+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
35 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
36 newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
37 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
38
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
39 var choice: array N of integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
40
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
41 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
42 queens(0, choice)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
43 end.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
44
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
45 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
46 15863724
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
47 16837425
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
48 17468253
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
49 17582463
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
50 24683175
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
51 25713864
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
52 25741863
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
53 26174835
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
54 26831475
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
55 27368514
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
56 27581463
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
57 28613574
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
58 31758246
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
59 35281746
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
60 35286471
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
61 35714286
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
62 35841726
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
63 36258174
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
64 36271485
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
65 36275184
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
66 36418572
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
67 36428571
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
68 36814752
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
69 36815724
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
70 36824175
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
71 37285146
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
72 37286415
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
73 38471625
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
74 41582736
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
75 41586372
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
76 42586137
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
77 42736815
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
78 42736851
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
79 42751863
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
80 42857136
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
81 42861357
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
82 46152837
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
83 46827135
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
84 46831752
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
85 47185263
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
86 47382516
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
87 47526138
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
88 47531682
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
89 48136275
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
90 48157263
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
91 48531726
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
92 51468273
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
93 51842736
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
94 51863724
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
95 52468317
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
96 52473861
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
97 52617483
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
98 52814736
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
99 53168247
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
100 53172864
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
101 53847162
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
102 57138642
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
103 57142863
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
104 57248136
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
105 57263148
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
106 57263184
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
107 57413862
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
108 58413627
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
109 58417263
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
110 61528374
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
111 62713584
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
112 62714853
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
113 63175824
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
114 63184275
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
115 63185247
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
116 63571428
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
117 63581427
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
118 63724815
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
119 63728514
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
120 63741825
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
121 64158273
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
122 64285713
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
123 64713528
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
124 64718253
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
125 68241753
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
126 71386425
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
127 72418536
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
128 72631485
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
129 73168524
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
130 73825164
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
131 74258136
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
132 74286135
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
133 75316824
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
134 82417536
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
135 82531746
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
136 83162574
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
137 84136275
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
138 >>*)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
139
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
140 (*[[
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
141 @ picoPascal compiler output
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
142 .include "fixup.s"
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
143 .global pmain
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
144
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
145 @ proc queens(k: integer; var choice: array N of integer);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
146 .text
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
147 _queens:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
148 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
149 stmfd sp!, {r0-r1}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
150 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
151 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
152 sub sp, sp, #8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
153 @ if k = N then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
154 ldr r0, [fp, #40]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
155 cmp r0, #8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
156 bne .L3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
157 @ print(choice)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
158 ldr r0, [fp, #44]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
159 bl _print
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
160 b .L1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
161 .L3:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
162 @ y := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
163 mov r4, #0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
164 .L5:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
165 @ while y < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
166 cmp r4, #8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
167 bge .L1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
168 @ j := 0; ok := true;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
169 mov r5, #0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
170 mov r0, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
171 strb r0, [fp, #-1]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
172 .L8:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
173 @ while ok and (j < k) do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
174 ldrb r0, [fp, #-1]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
175 cmp r0, #0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
176 beq .L10
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
177 ldr r7, [fp, #40]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
178 cmp r5, r7
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
179 bge .L10
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
180 @ q := choice[j];
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
181 ldr r0, [fp, #44]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
182 lsl r1, r5, #2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
183 add r0, r0, r1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
184 ldr r6, [r0]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
185 @ ok := (q <> y) and (q+j <> y+k) and (q-j <> y-k);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
186 cmp r6, r4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
187 mov r0, #0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
188 movne r0, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
189 add r1, r6, r5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
190 add r2, r4, r7
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
191 cmp r1, r2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
192 mov r1, #0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
193 movne r1, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
194 and r0, r0, r1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
195 sub r1, r6, r5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
196 sub r2, r4, r7
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
197 cmp r1, r2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
198 mov r1, #0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
199 movne r1, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
200 and r0, r0, r1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
201 strb r0, [fp, #-1]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
202 @ j := j+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
203 add r5, r5, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
204 b .L8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
205 .L10:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
206 @ if ok then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
207 ldrb r0, [fp, #-1]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
208 cmp r0, #0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
209 beq .L14
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
210 @ choice[k] := y;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
211 ldr r0, [fp, #44]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
212 ldr r1, [fp, #40]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
213 lsl r1, r1, #2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
214 add r0, r0, r1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
215 str r4, [r0]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
216 @ queens(k+1, choice)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
217 ldr r1, [fp, #44]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
218 ldr r0, [fp, #40]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
219 add r0, r0, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
220 bl _queens
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
221 .L14:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
222 @ y := y+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
223 add r4, r4, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
224 b .L5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
225 .L1:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
226 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
227 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
228
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
229 @ proc print(var choice: array N of integer);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
230 _print:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
231 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
232 stmfd sp!, {r0-r1}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
233 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
234 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
235 @ x := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
236 mov r4, #0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
237 .L16:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
238 @ while x < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
239 cmp r4, #8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
240 bge .L18
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
241 @ print_num(choice[x]+1);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
242 ldr r0, [fp, #40]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
243 lsl r1, r4, #2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
244 add r0, r0, r1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
245 ldr r0, [r0]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
246 add r0, r0, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
247 bl print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
248 @ x := x+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
249 add r4, r4, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
250 b .L16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
251 .L18:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
252 @ newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
253 bl newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
254 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
255 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
256
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
257 pmain:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
258 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
259 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
260 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
261 @ queens(0, choice)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
262 set r1, _choice
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
263 mov r0, #0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
264 bl _queens
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
265 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
266 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
267
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
268 .comm _choice, 32, 4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
269 @ End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
270 ]]*)