annotate ppc/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 MODULE Main 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
142 IMPORT Lib 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
143 ENDHDR
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
144
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
145 PROC _queens 16 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
146 ! if k = N then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
147 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
148 CONST 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
149 JNEQ L2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
150 ! print(choice)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
151 LDLW 20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
152 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
153 GLOBAL _print
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
154 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
155 JUMP L3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
156 LABEL L2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
157 ! y := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
158 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
159 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
160 ! while y < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
161 JUMP L5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
162 LABEL L4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
163 ! j := 0; ok := true;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
164 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
165 STLW -8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
166 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
167 STLC -13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
168 ! while ok and (j < k) do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
169 JUMP L8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
170 LABEL L7
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
171 ! q := choice[j];
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
172 LDLW 20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
173 LDLW -8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
174 LDIW
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
175 STLW -12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
176 ! ok := (q <> y) and (q+j <> y+k) and (q-j <> y-k);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
177 LDLW -12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
178 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
179 JEQ L12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
180 LDLW -12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
181 LDLW -8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
182 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
183 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
184 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
185 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
186 JEQ L12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
187 LDLW -12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
188 LDLW -8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
189 MINUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
190 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
191 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
192 MINUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
193 JEQ L12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
194 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
195 JUMP L13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
196 LABEL L12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
197 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
198 LABEL L13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
199 STLC -13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
200 ! j := j+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
201 LDLW -8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
202 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
203 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
204 STLW -8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
205 LABEL L8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
206 LDLC -13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
207 JNEQZ L10
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
208 JUMP L9
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
209 LABEL L10
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
210 LDLW -8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
211 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
212 JLT L7
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
213 LABEL L9
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
214 ! if ok then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
215 LDLC -13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
216 JNEQZ L16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
217 JUMP L18
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
218 LABEL L16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
219 ! choice[k] := y;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
220 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
221 LDLW 20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
222 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
223 STIW
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
224 ! queens(k+1, choice)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
225 LDLW 20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
226 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
227 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
228 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
229 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
230 GLOBAL _queens
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
231 PCALL 2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
232 LABEL L18
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
233 ! y := y+1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
234 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
235 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
236 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
237 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
238 LABEL L5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
239 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
240 CONST 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
241 JLT L4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
242 LABEL L3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
243 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
244 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
245
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
246 PROC _print 4 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
247 ! x := 0;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
248 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
249 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
250 ! while x < N do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
251 JUMP L20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
252 LABEL L19
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
253 ! print_num(choice[x]+1);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
254 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
255 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
256 LDIW
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
257 CONST 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
258 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
259 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
260 GLOBAL lib.print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
261 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
262 ! x := x+1
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 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
265 PLUS
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
266 STLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
267 LABEL L20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
268 LDLW -4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
269 CONST 8
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
270 JLT L19
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
271 ! newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
272 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
273 GLOBAL lib.newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
274 PCALL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
275 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
276 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
277
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
278 PROC MAIN 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
279 ! queens(0, choice)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
280 GLOBAL _choice
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
281 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
282 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
283 GLOBAL _queens
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
284 PCALL 2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
285 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
286 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
287
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
288 GLOVAR _choice 32
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
289 ! End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
290 ]]*)