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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
|
(*********************************************************************)
(* Copyright (C) 1998, Carl Eric Codere *)
(*********************************************************************)
(* FPC (Free Pascal compiler) testsuite: SETS *)
(* Tests the following: in, +, -, *, assignments. *)
(* for small sets amd large sets, both with constants *)
(* and variables. *)
(*********************************************************************)
const
failed: boolean = false;
type
myenum = (dA,dB,dC,dd,dedf,dg,dh,di,dj,dk,dl,dm,dn);
tasmop = (A_ABCD,
A_ADD,A_ADDA,A_ADDI,A_ADDQ,A_ADDX,A_AND,A_ANDI,
A_ASL,A_ASR,A_BCC,A_BCS,A_BEQ,A_BGE,A_BGT,A_BHI,
A_BLE,A_BLS,A_BLT,A_BMI,A_BNE,A_BPL,A_BVC,A_BVS,
A_BCHG,A_BCLR,A_BRA,A_BSET,A_BSR,A_BTST,A_CHK,
A_CLR,A_CMP,A_CMPA,A_CMPI,A_CMPM,A_DBCC,A_DBCS,A_DBEQ,A_DBGE,
A_DBGT,A_DBHI,A_DBLE,A_DBLS,A_DBLT,A_DBMI,A_DBNE,A_DBRA,
A_DBPL,A_DBT,A_DBVC,A_DBVS,A_DBF,A_DIVS,A_DIVU,
A_EOR,A_EORI,A_EXG,A_ILLEGAL,A_EXT,A_JMP,A_JSR,
A_LEA,A_LINK,A_LSL,A_LSR,A_MOVE,A_MOVEA,A_MOVEI,A_MOVEQ,
A_MOVEM,A_MOVEP,A_MULS,A_MULU,A_NBCD,A_NEG,A_NEGX,
A_NOP,A_NOT,A_OR,A_ORI,A_PEA,A_ROL,A_ROR,A_ROXL,
A_ROXR,A_RTR,A_RTS,A_SBCD,A_SCC,A_SCS,A_SEQ,A_SGE,
A_SGT,A_SHI,A_SLE,A_SLS,A_SLT,A_SMI,A_SNE,
A_SPL,A_ST,A_SVC,A_SVS,A_SF,A_SUB,A_SUBA,A_SUBI,A_SUBQ,
A_SUBX,A_SWAP,A_TAS,A_TRAP,A_TRAPV,A_TST,A_UNLK,
A_RTE,A_RESET,A_STOP,
{ MC68010 instructions }
A_BKPT,A_MOVEC,A_MOVES,A_RTD,
{ MC68020 instructions }
A_BFCHG,A_BFCLR,A_BFEXTS,A_BFEXTU,A_BFFFO,
A_BFINS,A_BFSET,A_BFTST,A_CALLM,A_CAS,A_CAS2,
A_CHK2,A_CMP2,A_DIVSL,A_DIVUL,A_EXTB,A_PACK,A_RTM,
A_TRAPCC,A_TRACS,A_TRAPEQ,A_TRAPF,A_TRAPGE,A_TRAPGT,
A_TRAPHI,A_TRAPLE,A_TRAPLS,A_TRAPLT,A_TRAPMI,A_TRAPNE,
A_TRAPPL,A_TRAPT,A_TRAPVC,A_TRAPVS,A_UNPK,
{ FPU Processor instructions - directly supported only. }
{ IEEE aware and misc. condition codes not supported }
A_FABS,A_FADD,
A_FBEQ,A_FBNE,A_FBNGT,A_FBGT,A_FBGE,A_FBNGE,
A_FBLT,A_FBNLT,A_FBLE,A_FBGL,A_FBNGL,A_FBGLE,A_FBNGLE,
A_FDBEQ,A_FDBNE,A_FDBGT,A_FDBNGT,A_FDBGE,A_FDBNGE,
A_FDBLT,A_FDBNLT,A_FDBLE,A_FDBGL,A_FDBNGL,A_FDBGLE,A_FBDNGLE,
A_FSEQ,A_FSNE,A_FSGT,A_FSNGT,A_FSGE,A_FSNGE,
A_FSLT,A_FSNLT,A_FSLE,A_FSGL,A_FSNGL,A_FSGLE,A_FSNGLE,
A_FCMP,A_FDIV,A_FMOVE,A_FMOVEM,
A_FMUL,A_FNEG,A_FNOP,A_FSQRT,A_FSUB,A_FSGLDIV,
A_FSFLMUL,A_FTST,
A_FTRAPEQ,A_FTRAPNE,A_FTRAPGT,A_FTRAPNGT,A_FTRAPGE,A_FTRAPNGE,
A_FTRAPLT,A_FTRAPNLT,A_FTRAPLE,A_FTRAPGL,A_FTRAPNGL,A_FTRAPGLE,A_FTRAPNGLE,
{ Protected instructions }
A_CPRESTORE,A_CPSAVE,
{ FPU Unit protected instructions }
{ and 68030/68851 common MMU instructions }
{ (this may include 68040 MMU instructions) }
A_FRESTORE,A_FSAVE,A_PFLUSH,A_PFLUSHA,A_PLOAD,A_PMOVE,A_PTEST,
{ Useful for assembly langage output }
A_LABEL,A_NONE);
Function X(y:myenum): myenum;
Begin
x:=y;
end;
Procedure SecondInSets;
{ SET_IN_BYTE TESTS }
var
op,op2 : tasmop;
oplist: set of tasmop;
Begin
Write('TESTING SET_IN_BYTE:');
oplist:=[];
op:=A_JSR;
if A_JSR in oplist then
begin
WriteLn('A_JSR in [] FAILED.');
failed := true
end
else
Writeln('A_JSR in [] PASSED.');
if op in oplist then
begin
WriteLn('op(A_JSR) in [] FAILED.');
failed := true
end
else
Writeln('op (A_JSR) in [] PASSED.');
op:=A_MOVE;
oplist:=oplist+[A_MOVE];
if A_MOVE in oplist then
WriteLn('A_MOVE in ([]+[A_MOVE]) PASSED.')
else
begin
Writeln('A_MOVE in ([]+[A_MOVE]) FAILED.');
failed := true;
end;
if op in oplist then
WriteLn('op(A_MOVE) in ([]+[A_MOVE]) PASSED.')
else
begin
Writeln('op(A_MOVE) in ([]+[A_MOVE]) FAILED.');
failed := true;
end;
op:=A_MOVE;
oplist:=[];
oplist:=[A_SUB]+[op];
op2:=A_MOVE;
if A_MOVE in oplist then
WriteLn('A_MOVE in ([A_SUB]+[op(A_MOVE)]) PASSED.')
else
begin
Writeln('A_MOVE in ([A_SUB]+[op(A_MOVE)]) FAILED.');
failed := true
end;
if op2 in oplist then
WriteLn('op2(A_MOVE) in ([A_SUB]+[op(A_MOVE)]) PASSED.')
else
begin
Writeln('op2(A_MOVE) in ([A_SUB]+[op(A_MOVE)]) FAILED.');
failed := true
end;
end;
Procedure SetSetByte;
{ SET_SET_BYTE }
var
op : tasmop;
oplist: set of tasmop;
Begin
Write('TESTING SET_SET_BYTE(1):');
op:=A_LABEL;
oplist:=[];
oplist:=oplist+[op];
if op in oplist then
Begin
WriteLn(' PASSED.');
end
else
Begin
WriteLn(' FAILED.');
failed := true
end;
Write('TESTING INCLUDE:');
op:=A_RTE;
include(oplist,op);
if op in oplist then
Begin
WriteLn(' PASSED.');
end
else
Begin
WriteLn(' FAILED.');
failed := true;
end;
end;
Procedure SetAddSets;
{ SET_ADD_SETS }
var
op2list :set of tasmop;
oplist: set of tasmop;
Begin
op2list:=[];
oplist:=[];
oplist:=[A_MOVE]+[A_JSR];
op2list:=[A_LABEL];
oplist:=op2list+oplist;
if A_MOVE in oplist then
if A_LABEL in oplist then
if A_JSR in oplist then
WriteLn('TESTING SET_ADD_SETS: PASSED.')
else
begin
WriteLn('TESTING SET_ADD_SETS: FAILED.');
failed := true
end
else
begin
WriteLn('TESTING SET_ADD_SETS: FAILED.');
failed := true
end
else
begin
WriteLn('TESTING SET_ADD_SETS: FAILED.');
failed := true
end;
end;
Procedure SetSubsets;
{ SET_SUB_SETS }
var
op2list :set of tasmop;
oplist: set of tasmop;
Begin
op2list:=[];
oplist:=[];
oplist:=[A_MOVE]+[A_JSR];
op2list:=[A_MOVE]+[A_JSR];
oplist:=op2list-oplist;
if (A_MOVE in oplist) or (A_LABEL in oplist) or (A_JSR in oplist) then
begin
WriteLn('TESTING SET_SUB_SETS: FAILED.');
failed := true
end
else
WriteLn('TESTING SET_SUB_SETS: PASSED.');
oplist := [A_MOVE,A_RTE];
exclude(oplist,A_MOVE);
if (A_MOVE in oplist) then
begin
WriteLn('TESTING EXCLUDE: FAILED.');
failed := true
end
else
WriteLn('TESTING EXCLUDE: PASSED.')
end;
Procedure SetCompSets;
{ SET_COMP_SETS }
var
op2list :set of tasmop;
oplist: set of tasmop;
Begin
op2list:=[];
oplist:=[];
oplist:=[A_MOVE]+[A_JSR];
op2list:=[A_MOVE]+[A_JSR];
if oplist=op2list then
WriteLn('TESTING SET_COMP_SETS(1): PASSED.')
else
begin
WriteLn('TESTING SET_COMP_SETS(1): FAILED.');
failed := true
end;
oplist:=[A_MOVE];
if oplist=op2list then
begin
WriteLn('TESTING SET_COMP_SETS(2): FAILED.');
failed := true
end
else
WriteLn('TESTING SET_COMP_SETS(2): PASSED.');
end;
Procedure SetMulSets;
{ SET_COMP_SETS }
var
op2list :set of tasmop;
oplist: set of tasmop;
Begin
op2list:=[];
oplist:=[];
oplist:=[A_MOVE]+[A_JSR];
op2list:=[A_MOVE];
oplist:=oplist*op2list;
if A_JSR in oplist then
begin
WriteLn('TESTING SET_MUL_SETS(1): FAILED.');
failed := true
end
else
WriteLn('TESTING SET_MUL_SETS(1): PASSED.');
if A_MOVE in oplist then
WriteLn('TESTING SET_MUL_SETS(2): PASSED.')
else
begin
WriteLn('TESTING SET_MUL_SETS(2): FAILED.');
failed := true
end;
end;
{------------------------------ TESTS FOR SMALL VALUES ---------------------}
Procedure SmallInSets;
{ SET_IN_BYTE TESTS }
var
op : myenum;
oplist: set of myenum;
Begin
Write('TESTING IN_BYTE:');
oplist:=[];
op:=Dn;
if op in oplist then
begin
WriteLn(' FAILED.');
failed := true
end;
op:=dm;
oplist:=oplist+[Dm];
if op in oplist then
WriteLn(' PASSED.')
else
begin
WriteLn(' FAILED.');
failed := true
end;
end;
Procedure SmallSetByte;
{ SET_SET_BYTE }
var
op : myenum;
oplist: set of myenum;
Begin
Write('TESTING SET_BYTE(1):');
op:=DA;
oplist:=[];
oplist:=oplist+[op];
if op in oplist then
Begin
WriteLn(' PASSED.');
end
else
Begin
WriteLn(' FAILED.');
failed := true;
end;
end;
Procedure SmallAddSets;
{ SET_ADD_SETS }
var
op2list :set of myenum;
oplist: set of myenum;
Begin
op2list:=[];
oplist:=[];
oplist:=[DA]+[DC];
op2list:=[DB];
oplist:=op2list+oplist;
if DA in oplist then
if DC in oplist then
if DB in oplist then
WriteLn('TESTING SET_ADD_SETS: PASSED.')
else
begin
WriteLn('TESTING ADD_SETS: FAILED.');
failed := true
end
else
begin
WriteLn('TESTING ADD_SETS: FAILED.');
failed := true
end
else
begin
WriteLn('TESTING ADD_SETS: FAILED.');
failed := true
end;
end;
Procedure SmallSubsets;
{ SET_SUB_SETS }
var
op2list :set of myenum;
oplist: set of myenum;
Begin
op2list:=[];
oplist:=[];
oplist:=[DA]+[DC];
op2list:=[DA]+[DC];
oplist:=op2list-oplist;
if (DA in oplist) or (DB in oplist) or (DC in oplist) then
begin
WriteLn('TESTING SUB_SETS: FAILED.');
failed := true
end
else
WriteLn('TESTING SUB_SETS: PASSED.')
end;
Procedure SmallCompSets;
{ SET_COMP_SETS }
var
op2list :set of myenum;
oplist: set of myenum;
Begin
op2list:=[];
oplist:=[];
oplist:=[DA]+[DC];
op2list:=[DA]+[DC];
if oplist=op2list then
WriteLn('TESTING COMP_SETS(1): PASSED.')
else
begin
WriteLn('TESTING COMP_SETS(1): FAILED.');
failed := true
end;
oplist:=[DA];
if oplist=op2list then
begin
WriteLn('TESTING COMP_SETS(2): FAILED.');
failed := true
end
else
WriteLn('TESTING COMP_SETS(2): PASSED.');
end;
Procedure SmallMulSets;
{ SET_COMP_SETS }
var
op2list :set of myenum;
oplist: set of myenum;
Begin
op2list:=[];
oplist:=[];
oplist:=[DA]+[DC];
op2list:=[DA];
oplist:=oplist*op2list;
if DC in oplist then
begin
WriteLn('TESTING MUL_SETS(1): FAILED.');
failed := true
end
else
WriteLn('TESTING MUL_SETS(1): PASSED.');
if DA in oplist then
WriteLn('TESTING MUL_SETS(2): PASSED.')
else
begin
WriteLn('TESTING MUL_SETS(2): FAILED.');
failed := true
end;
end;
const
b: myenum = (dA);
var
enum: set of myenum;
oplist: set of tasmop;
l : word;
Begin
{ small sets }
enum:=[];
{ add }
enum:=enum+[da];
{ subtract }
enum:=enum-[da];
if DA in enum then
WriteLn('Found A_LABEL');
{ very large sets }
{ copy loop test }
WRITELN('LARGE SETS:');
oplist := [A_LABEL];
{ secondin test }
if A_LABEL in oplist then
WriteLn('TESTING SIMPLE SECOND_IN: PASSED.')
else
begin
failed := true
end;
{ }
oplist:=[];
if A_LABEL in oplist then
begin
WriteLn('SECOND IN FAILED.');
failed := true
end;
SecondinSets;
SetSetByte;
SetAddSets;
SetSubSets;
SetCompSets;
SetMulSets;
WRITELN('SMALL SETS:');
SmallInSets;
SmallAddSets;
SmallSubSets;
SmallCompSets;
SmallMulSets;
l:=word(A_CPRESTORE);
if l = word(A_CPRESTORE) then
Begin
end
else failed := true;
if failed then
begin
WriteLn('One or more test failed');
Halt(1);
end;
end.
|