annotate ppc/test/queens3.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 bitmap arrays *)
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 var
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 choice: array N of integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 rank: array N of boolean;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 diagup, diagdown: array 2 * N - 1 of boolean;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 proc queens(k: integer);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11 var y, j, q: integer; ok: boolean;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 if k = N then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 print()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 else
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 y := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 while y < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18 if rank[y] and diagup[k+y] and diagdown[k-y+N-1] then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 rank[y] := false; diagup[k+y] := false; diagdown[k-y+N-1] := false;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20 choice[k] := y; queens(k+1);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 rank[y] := true; diagup[k+y] := true; diagdown[k-y+N-1] := true;
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();
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 proc init();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
40 var i: integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
41 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
42 i := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
43 while i < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
44 rank[i] := true;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
45 i := i+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
46 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
47 i := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
48 while i < 2*N-1 do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
49 diagup[i] := true; diagdown[i] := true ;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
50 i := i+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
51 end
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
52 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
53
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
54 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
55 init();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
56 queens(0)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
57 end.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
58
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
59 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
60 15863724
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
61 16837425
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
62 17468253
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
63 17582463
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
64 24683175
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
65 25713864
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
66 25741863
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
67 26174835
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
68 26831475
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
69 27368514
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
70 27581463
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
71 28613574
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
72 31758246
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
73 35281746
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
74 35286471
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
75 35714286
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
76 35841726
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
77 36258174
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
78 36271485
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
79 36275184
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
80 36418572
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
81 36428571
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
82 36814752
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
83 36815724
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
84 36824175
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
85 37285146
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
86 37286415
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
87 38471625
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
88 41582736
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
89 41586372
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
90 42586137
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
91 42736815
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
92 42736851
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
93 42751863
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
94 42857136
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
95 42861357
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
96 46152837
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
97 46827135
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
98 46831752
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
99 47185263
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
100 47382516
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
101 47526138
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
102 47531682
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
103 48136275
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
104 48157263
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
105 48531726
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
106 51468273
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
107 51842736
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
108 51863724
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
109 52468317
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
110 52473861
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
111 52617483
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
112 52814736
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
113 53168247
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
114 53172864
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
115 53847162
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
116 57138642
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
117 57142863
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
118 57248136
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
119 57263148
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
120 57263184
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
121 57413862
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
122 58413627
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
123 58417263
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
124 61528374
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
125 62713584
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
126 62714853
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
127 63175824
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
128 63184275
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
129 63185247
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
130 63571428
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
131 63581427
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
132 63724815
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
133 63728514
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
134 63741825
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
135 64158273
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
136 64285713
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
137 64713528
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
138 64718253
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
139 68241753
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
140 71386425
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
141 72418536
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
142 72631485
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
143 73168524
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
144 73825164
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
145 74258136
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
146 74286135
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
147 75316824
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
148 82417536
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
149 82531746
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
150 83162574
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
151 84136275
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
152 >>*)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
153
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
154 (*[[
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
155 MODULE Main 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
156 IMPORT Lib 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
157 ENDHDR
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
158
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
159 PROC _queens 16 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
160 ! if k = N then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
161 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
162 CONST 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
163 JNEQ L2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
164 ! print()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
165 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
166 GLOBAL _print
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
167 PCALL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
168 JUMP L3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
169 LABEL L2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
170 ! y := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
171 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
172 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
173 ! while y < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
174 JUMP L5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
175 LABEL L4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
176 ! if rank[y] and diagup[k+y] and diagdown[k-y+N-1] then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
177 GLOBAL _rank
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
178 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
179 LDIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
180 JNEQZ L11
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
181 JUMP L9
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
182 LABEL L11
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
183 GLOBAL _diagup
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
184 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
185 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
186 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
187 LDIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
188 JNEQZ L10
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
189 JUMP L9
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
190 LABEL L10
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
191 GLOBAL _diagdown
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
192 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
193 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
194 MINUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
195 CONST 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
196 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
197 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
198 MINUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
199 LDIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
200 JNEQZ L7
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
201 JUMP L9
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
202 LABEL L7
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
203 ! rank[y] := false; diagup[k+y] := false; diagdown[k-y+N-1] := false;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
204 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
205 GLOBAL _rank
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
206 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
207 STIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
208 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
209 GLOBAL _diagup
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
210 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
211 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
212 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
213 STIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
214 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
215 GLOBAL _diagdown
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
216 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
217 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
218 MINUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
219 CONST 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
220 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
221 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
222 MINUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
223 STIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
224 ! choice[k] := y; queens(k+1);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
225 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
226 GLOBAL _choice
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
227 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
228 STIW
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
229 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
230 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
231 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
232 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
233 GLOBAL _queens
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
234 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
235 ! rank[y] := true; diagup[k+y] := true; diagdown[k-y+N-1] := true;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
236 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
237 GLOBAL _rank
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
238 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
239 STIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
240 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
241 GLOBAL _diagup
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
242 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
243 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
244 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
245 STIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
246 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
247 GLOBAL _diagdown
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
248 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
249 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
250 MINUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
251 CONST 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
252 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
253 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
254 MINUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
255 STIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
256 LABEL L9
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
257 ! y := y+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
258 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
259 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
260 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
261 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
262 LABEL L5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
263 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
264 CONST 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
265 JLT L4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
266 LABEL L3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
267 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
268 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
269
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
270 PROC _print 4 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
271 ! x := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
272 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
273 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
274 ! while x < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
275 JUMP L13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
276 LABEL L12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
277 ! print_num(choice[x]+1);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
278 GLOBAL _choice
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
279 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
280 LDIW
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
281 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
282 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
283 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
284 GLOBAL lib.print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
285 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
286 ! x := x+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
287 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
288 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
289 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
290 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
291 LABEL L13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
292 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
293 CONST 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
294 JLT L12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
295 ! newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
296 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
297 GLOBAL lib.newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
298 PCALL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
299 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
300 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
301
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
302 PROC _init 4 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
303 ! i := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
304 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
305 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
306 ! while i < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
307 JUMP L16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
308 LABEL L15
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
309 ! rank[i] := true;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
310 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
311 GLOBAL _rank
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
312 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
313 STIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
314 ! i := i+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
315 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
316 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
317 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
318 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
319 LABEL L16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
320 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
321 CONST 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
322 JLT L15
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
323 ! i := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
324 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
325 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
326 ! while i < 2*N-1 do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
327 JUMP L19
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
328 LABEL L18
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
329 ! diagup[i] := true; diagdown[i] := true ;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
330 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
331 GLOBAL _diagup
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
332 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
333 STIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
334 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
335 GLOBAL _diagdown
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
336 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
337 STIC
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
338 ! i := i+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
339 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
340 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
341 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
342 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
343 LABEL L19
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
344 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
345 CONST 15
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
346 JLT L18
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
347 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
348 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
349
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
350 PROC MAIN 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
351 ! init();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
352 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
353 GLOBAL _init
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
354 PCALL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
355 ! queens(0)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
356 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
357 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
358 GLOBAL _queens
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
359 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
360 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
361 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
362
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
363 GLOVAR _choice 32
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
364 GLOVAR _rank 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
365 GLOVAR _diagup 15
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
366 GLOVAR _diagdown 15
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
367 ! End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
368 ]]*)