summaryrefslogtreecommitdiff
path: root/sim/testsuite/h8300/cmpb.s
blob: 1a4f23c8b293a44dee8f6737ea3d4f3d178dce05 (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
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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
# Hitachi H8 testcase 'cmp.b'
# mach(): all
# as(h8300):	--defsym sim_cpu=0
# as(h8300h):	--defsym sim_cpu=1
# as(h8300s):	--defsym sim_cpu=2
# as(h8sx):	--defsym sim_cpu=3
# ld(h8300h):	-m h8300helf	
# ld(h8300s):	-m h8300self	
# ld(h8sx):	-m h8300sxelf

	.include "testutils.inc"

	# Instructions tested:
	# cmp.b #xx:8, rd	;                     a rd   xxxxxxxx
	# cmp.b #xx:8, @erd	;         7 d rd ???? a ???? xxxxxxxx
	# cmp.b #xx:8, @erd+	; 0 1 7 4 6 c rd 1??? a ???? xxxxxxxx
	# cmp.b #xx:8, @erd-	; 0 1 7 6 6 c rd 1??? a ???? xxxxxxxx
	# cmp.b #xx:8, @+erd	; 0 1 7 5 6 c rd 1??? a ???? xxxxxxxx
	# cmp.b #xx:8, @-erd	; 0 1 7 7 6 c rd 1??? a ???? xxxxxxxx
	# cmp.b rs, rd		;                     1 c rs rd
	# cmp.b reg8, @erd	;         7 d rd ???? 1 c rs ????
	# cmp.b reg8, @erd+	;         0 1 7     9 8 rd 2 rs
	# cmp.b reg8, @erd-	;         0 1 7     9 a rd 2 rs
	# cmp.b reg8, @+erd	;         0 1 7     9 9 rd 2 rs
	# cmp.b reg8, @-erd	;         0 1 7     9 b rd 2 rs
	# cmp.b rsind, rdind	     ; 7 c 0rs 5 0 ?rd 2 ????
	# cmp.b rspostinc, rdpostinc ; 0 1 7 4 6 c 0rs c 8 ?rd 2 ????
	# cmp.b rspostdec, rdpostdec ; 0 1 7 6 6 c 0rs c a ?rd 2 ????
	# cmp.b rspreinc, rdpreinc   ; 0 1 7 5 6 c 0rs c 9 ?rd 2 ????
	# cmp.b rspredec, rdpredec   ; 0 1 7 7 6 c 0rs c b ?rd 2 ????
	# cmp.b disp2, disp2	     ; 0 1 7 01dd:2 6 8 0rs c 00dd:2 ?rd 2 ????
	# cmp.b disp16, disp16	     ; 0 1 7 4 6 e 0rs c dd:16 c 0rd 2 ???? dd:16
	# cmp.b disp32, disp32	     ; 7 8 0rs 4 6 a 2 c dd:32 c 1rd 2 ???? dd:32
	# cmp.b indexb16, indexb16   ; 0 1 7 5 6 e 0rs c dd:16 d 0rd 2 ???? dd:16
	# cmp.b indexw16, indexw16   ; 0 1 7 6 6 e 0rs c dd:16 e 0rd 2 ???? dd:16
	# cmp.b indexl16, indexl16   ; 0 1 7 7 6 e 0rs c dd:16 f 0rd 2 ???? dd:16
	# cmp.b indexb32, indexb32   ; 7 8 0rs 5 6 a 2 c dd:32 d 1rd 2 ???? dd:32
	# cmp.b indexw32, indexw32   ; 7 8 0rs 6 6 a 2 c dd:32 e 1rd 2 ???? dd:32
	# cmp.b indexl32, indexl32   ; 7 8 0rs 7 6 a 2 c dd:32 f 1rd 2 ???? dd:32
	# cmp.b abs16, abs16	     ; 6 a 1 5 aa:16 4 0??? 2 ???? aa:16
	# cmp.b abs32, abs32	     ; 6 a 3 5 aa:32 4 1??? 2 ???? aa:32
	#

	# Coming soon:
	
	# ...

.data
byte_src:	.byte 0x5a
pre_byte:	.byte 0
byte_dst:	.byte 0xa5
post_byte:	.byte 0

	start
	
cmp_b_imm8_reg8:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	;;  fixme set ccr

	;;  cmp.b #xx:8,Rd
	cmp.b	#0xa5, r0l	; Immediate 8-bit src, reg8 dest
	beq	.Leq1
	fail
.Leq1:	cmp.b	#0xa6, r0l
	blt	.Llt1
	fail
.Llt1:	cmp.b	#0xa4, r0l
	bgt	.Lgt1
	fail
.Lgt1:	
	;; fixme test ccr	; H=0 N=1 Z=0 V=0 C=0
	test_h_gr16 0xa5a5 r0	; r0 unchanged
.if (sim_cpu)			; non-zero means h8300h, s, or sx
	test_h_gr32 0xa5a5a5a5 er0	; er0 unchanged
.endif
	test_gr_a5a5 1		; Make sure other general regs not disturbed
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7
	
.if (sim_cpu == h8sx)
cmp_b_imm8_rdind:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  cmp.b #xx:8,@eRd
	mov	#byte_dst, er0
	cmp.b	#0xa5:8, @er0	; Immediate 8-bit src, reg indirect dst
;;; 	.word	0x7d00
;;; 	.word	0xa0a5
	beq	.Leq2
	fail
.Leq2:	set_ccr_zero
	cmp.b	#0xa6, @er0
;;; 	.word	0x7d00
;;; 	.word	0xa0a6
	blt	.Llt2
	fail
.Llt2:	set_ccr_zero
	cmp.b	#0xa4, @er0
;;; 	.word	0x7d00
;;; 	.word	0xa0a4
	bgt	.Lgt2
	fail
.Lgt2:		
	test_carry_clear	; H=0 N=0 Z=0 V=0 C=0
	test_ovf_clear
	test_zero_clear
	test_neg_clear
	
	test_h_gr32 byte_dst er0	; er0 still contains address
	test_gr_a5a5 1		; Make sure other general regs not disturbed
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

	;; Now check the result of the cmp to memory (memory unchanged).
	sub.b	r0l, r0l
	mov.b	@byte_dst, r0l
	cmp.b	#0xa5, r0l
	beq	.L2
	fail
.L2:

cmp_b_imm8_rdpostinc:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  cmp.b #xx:8,@eRd+
	mov	#byte_dst, er0
	cmp.b	#0xa5:8, @er0+	; Immediate 8-bit src, reg postinc dst
;;; 	.word	0x0174
;;; 	.word	0x6c08
;;; 	.word	0xa0a5
	beq	.Leq3
	fail
.Leq3:	test_h_gr32 post_byte er0	; er0 contains address plus one
	mov	#byte_dst, er0
	set_ccr_zero
	cmp.b	#0xa6, @er0+
;;; 	.word	0x0174
;;; 	.word	0x6c08
;;; 	.word	0xa0a6
	blt	.Llt3
	fail
.Llt3:	test_h_gr32 post_byte er0	; er0 contains address plus one
	mov	#byte_dst, er0
	set_ccr_zero
	cmp.b	#0xa4, @er0+
;;; 	.word	0x0174
;;; 	.word	0x6c08
;;; 	.word	0xa0a4
	bgt	.Lgt3
	fail
.Lgt3:
	test_carry_clear	; H=0 N=0 Z=0 V=0 C=0
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	test_h_gr32 post_byte er0	; er0 contains address plus one
	test_gr_a5a5 1		; Make sure other general regs not disturbed
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

	;; Now check the result of the cmp to memory (memory unchanged).
	sub.b	r0l, r0l
	mov.b	@byte_dst, r0l
	cmp.b	#0xa5, r0l
	beq	.L3
	fail
.L3:

cmp_b_imm8_rdpostdec:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  cmp.b #xx:8,@eRd-
	mov	#byte_dst, er0
	cmp.b	#0xa5:8, @er0-	; Immediate 8-bit src, reg postdec dst
;;; 	.word	0x0176
;;; 	.word	0x6c08
;;; 	.word	0xa0a5
	beq	.Leq4
	fail
.Leq4:	test_h_gr32 pre_byte er0	; er0 contains address minus one
	mov	#byte_dst, er0
	set_ccr_zero
	cmp.b	#0xa6, @er0-
;;; 	.word	0x0176
;;; 	.word	0x6c08
;;; 	.word	0xa0a6
	blt	.Llt4
	fail
.Llt4:	test_h_gr32 pre_byte er0	; er0 contains address minus one
	mov	#byte_dst, er0
	set_ccr_zero
	cmp.b	#0xa4, @er0-
;;; 	.word	0x0176
;;; 	.word	0x6c08
;;; 	.word	0xa0a4
	bgt	.Lgt4
	fail
.Lgt4:
	test_carry_clear	; H=0 N=0 Z=0 V=0 C=0
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	test_h_gr32 pre_byte er0	; er0 contains address minus one
	test_gr_a5a5 1		; Make sure other general regs not disturbed
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

	;; Now check the result of the cmp to memory (memory unchanged).
	sub.b	r0l, r0l
	mov.b	@byte_dst, r0l
	cmp.b	#0xa5, r0l
	beq	.L4
	fail
.L4:

cmp_b_imm8_rdpreinc:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  cmp.b #xx:8,@+eRd
	mov	#pre_byte, er0
	cmp.b	#0xa5:8, @+er0	; Immediate 8-bit src, reg pre-inc dst
;;; 	.word	0x0175
;;; 	.word	0x6c08
;;; 	.word	0xa0a5
	beq	.Leq5
	fail
.Leq5:	test_h_gr32 byte_dst er0	; er0 contains destination address 
	mov	#pre_byte, er0
	set_ccr_zero
	cmp.b	#0xa6, @+er0
;;; 	.word	0x0175
;;; 	.word	0x6c08
;;; 	.word	0xa0a6
	blt	.Llt5
	fail
.Llt5:	test_h_gr32 byte_dst er0	; er0 contains destination address 
	mov	#pre_byte, er0
	set_ccr_zero
	cmp.b	#0xa4, @+er0
;;; 	.word	0x0175
;;; 	.word	0x6c08
;;; 	.word	0xa0a4
	bgt	.Lgt5
	fail
.Lgt5:
	test_carry_clear	; H=0 N=0 Z=0 V=0 C=0
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	test_h_gr32 byte_dst er0	; er0 contains destination address 
	test_gr_a5a5 1		; Make sure other general regs not disturbed
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

	;; Now check the result of the cmp to memory (memory unchanged).
	sub.b	r0l, r0l
	mov.b	@byte_dst, r0l
	cmp.b	#0xa5, r0l
	beq	.L5
	fail
.L5:

cmp_b_imm8_rdpredec:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  cmp.b #xx:8,@-eRd
	mov	#post_byte, er0
	cmp.b	#0xa5:8, @-er0	; Immediate 8-bit src, reg pre-dec dst
;;; 	.word	0x0177
;;; 	.word	0x6c08
;;; 	.word	0xa0a5
	beq	.Leq6
	fail
.Leq6:	test_h_gr32 byte_dst er0	; er0 contains destination address 
	mov	#post_byte, er0
	set_ccr_zero
	cmp.b	#0xa6, @-er0
;;; 	.word	0x0177
;;; 	.word	0x6c08
;;; 	.word	0xa0a6
	blt	.Llt6
	fail
.Llt6:	test_h_gr32 byte_dst er0	; er0 contains destination address 
	mov	#post_byte, er0
	set_ccr_zero
	cmp.b	#0xa4, @-er0
;;; 	.word	0x0177
;;; 	.word	0x6c08
;;; 	.word	0xa0a4
	bgt	.Lgt6
	fail
.Lgt6:
	test_carry_clear	; H=0 N=0 Z=0 V=0 C=0
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	test_h_gr32 byte_dst er0	; er0 contains destination address 
	test_gr_a5a5 1		; Make sure other general regs not disturbed
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

	;; Now check the result of the cmp to memory (memory unchanged).
	sub.b	r0l, r0l
	mov.b	@byte_dst, r0l
	cmp.b	#0xa5, r0l
	beq	.L6
	fail
.L6:


.endif

cmp_b_reg8_reg8:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	;;  fixme set ccr

	;;  cmp.b Rs,Rd
	mov.b	#0xa5, r0h
	cmp.b	r0h, r0l	; Reg8 src, reg8 dst
	beq	.Leq7
	fail
.Leq7:	mov.b	#0xa6, r0h
	cmp.b	r0h, r0l
	blt	.Llt7
	fail
.Llt7:	mov.b	#0xa4, r0h
	cmp.b	r0h, r0l
	bgt	.Lgt7
	fail
.Lgt7:
	;; fixme test ccr	; H=0 N=1 Z=0 V=0 C=0
	test_h_gr16 0xa4a5 r0	; r0l unchanged.
.if (sim_cpu)			; non-zero means h8300h, s, or sx
	test_h_gr32 0xa5a5a4a5 er0	; r0l unchanged
.endif
	test_gr_a5a5 1		; Make sure other general regs not disturbed
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7
	
.if (sim_cpu == h8sx)
cmp_b_reg8_rdind:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  cmp.b rs8,@eRd	; cmp reg8 to register indirect
	mov	#byte_dst, er0
	mov	#0xa5, r1l
	cmp.b	r1l, @er0	; reg8 src, reg indirect dest
;;; 	.word	0x7d00
;;; 	.word	0x1c90
	beq	.Leq8
	fail
.Leq8:	set_ccr_zero
	mov	#0xa6, r1l
	cmp.b	r1l, @er0
;;; 	.word	0x7d00
;;; 	.word	0x1c90
	blt	.Llt8
	fail
.Llt8:	set_ccr_zero
	mov	#0xa4, r1l
	cmp.b	r1l, @er0
;;; 	.word	0x7d00
;;; 	.word	0x1c90
	bgt	.Lgt8
	fail
.Lgt8:
	test_carry_clear	; H=0 N=0 Z=0 V=0 C=0
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	test_h_gr32 byte_dst er0	; er0 still contains address
	test_h_gr32 0xa5a5a5a4 er1	; er1 has the test load

	test_gr_a5a5 2		; Make sure other general regs not disturbed
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

	;; Now check the result of the cmp to memory (no change).
	sub.b	r0l, r0l
	mov.b	@byte_dst, r0l
	cmp.b	#0xa5, r0l
	beq	.L8
	fail
.L8:

cmp_b_reg8_rdpostinc:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  cmp.b reg8,@eRd+
	mov	#byte_dst, er0
	mov	#0xa5, r1l
	cmp.b	r1l, @er0+	; Immediate 8-bit src, reg post-incr dst
;;; 	.word	0x0179
;;; 	.word	0x8029
	beq	.Leq9
	fail
.Leq9:	test_h_gr32 post_byte er0	; er0 contains address plus one
	mov	#byte_dst er0
	mov	#0xa6, r1l
	set_ccr_zero
	cmp.b	r1l, @er0+
;;; 	.word	0x0179
;;; 	.word	0x8029
	blt	.Llt9
	fail
.Llt9:	test_h_gr32 post_byte er0	; er0 contains address plus one
	mov	#byte_dst er0
	mov	#0xa4, r1l
	set_ccr_zero
	cmp.b	r1l, @er0+
;;; 	.word	0x0179
;;; 	.word	0x8029
	bgt	.Lgt9
	fail
.Lgt9:
	test_carry_clear	; H=0 N=0 Z=0 V=0 C=0
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	test_h_gr32 post_byte er0	; er0 contains address plus one
	test_h_gr32 0xa5a5a5a4 er1	; er1 contains test load
	test_gr_a5a5 2		; Make sure other general regs not disturbed
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

	;; Now check the result of the cmp to memory (memory unchanged).
	sub.b	r0l, r0l
	mov.b	@byte_dst, r0l
	cmp.b	#0xa5, r0l
	beq	.L9
	fail
.L9:

cmp_b_reg8_rdpostdec:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  cmp.b reg8,@eRd-
	mov	#byte_dst, er0
	mov	#0xa5, r1l
	cmp.b	r1l, @er0-	; Immediate 8-bit src, reg postdec dst
;;; 	.word	0x0179
;;; 	.word	0xa029
	beq	.Leq10
	fail
.Leq10:	test_h_gr32 pre_byte er0	; er0 contains address minus one
	mov	#byte_dst er0
	mov	#0xa6, r1l
	set_ccr_zero
	cmp.b	r1l, @er0-
;;; 	.word	0x0179
;;; 	.word	0xa029
	blt	.Llt10
	fail
.Llt10:	test_h_gr32 pre_byte er0	; er0 contains address minus one
	mov	#byte_dst er0
	mov	#0xa4, r1l
	set_ccr_zero
	cmp.b	r1l, @er0-
;;; 	.word	0x0179
;;; 	.word	0xa029
	bgt	.Lgt10
	fail
.Lgt10:
	test_carry_clear	; H=0 N=0 Z=0 V=0 C=0
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	test_h_gr32 pre_byte er0	; er0 contains address minus one
	test_h_gr32 0xa5a5a5a4 er1	; er1 contains test load
	test_gr_a5a5 2		; Make sure other general regs not disturbed
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

	;; Now check the result of the cmp to memory (memory unchanged).
	sub.b	r0l, r0l
	mov.b	@byte_dst, r0l
	cmp.b	#0xa5, r0l
	beq	.L10
	fail
.L10:

cmp_b_reg8_rdpreinc:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  cmp.b reg8,@+eRd
	mov	#pre_byte, er0
	mov	#0xa5, r1l
	cmp.b	r1l, @+er0	; Immediate 8-bit src, reg post-incr dst
;;; 	.word	0x0179
;;; 	.word	0x9029
	beq	.Leq11
	fail
.Leq11:	test_h_gr32 byte_dst er0	; er0 contains destination address 
	mov	#pre_byte er0
	mov	#0xa6, r1l
	set_ccr_zero
	cmp.b	r1l, @+er0
;;; 	.word	0x0179
;;; 	.word	0x9029
	blt	.Llt11
	fail
.Llt11:	test_h_gr32 byte_dst er0	; er0 contains destination address 
	mov	#pre_byte er0
	mov	#0xa4, r1l
	set_ccr_zero
	cmp.b	r1l, @+er0
;;; 	.word	0x0179
;;; 	.word	0x9029
	bgt	.Lgt11
	fail
.Lgt11:
	test_carry_clear	; H=0 N=0 Z=0 V=0 C=0
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	test_h_gr32 byte_dst er0	; er0 contains destination address 
	test_h_gr32 0xa5a5a5a4 er1	; er1 contains test load
	test_gr_a5a5 2		; Make sure other general regs not disturbed
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

	;; Now check the result of the cmp to memory (memory unchanged).
	sub.b	r0l, r0l
	mov.b	@byte_dst, r0l
	cmp.b	#0xa5, r0l
	beq	.L11
	fail
.L11:

cmp_b_reg8_rdpredec:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  cmp.b reg8,@-eRd
	mov	#post_byte, er0
	mov	#0xa5, r1l
	cmp.b	r1l, @-er0	; Immediate 8-bit src, reg postdec dst
;;; 	.word	0x0179
;;; 	.word	0xb029
	beq	.Leq12
	fail
.Leq12:	test_h_gr32 byte_dst er0	; er0 contains destination address 
	mov	#post_byte er0
	mov	#0xa6, r1l
	set_ccr_zero
	cmp.b	r1l, @-er0
;;; 	.word	0x0179
;;; 	.word	0xb029
	blt	.Llt12
	fail
.Llt12:	test_h_gr32 byte_dst er0	; er0 contains destination address 
	mov	#post_byte er0
	mov	#0xa4, r1l
	set_ccr_zero
	cmp.b	r1l, @-er0
;;; 	.word	0x0179
;;; 	.word	0xb029
	bgt	.Lgt12
	fail
.Lgt12:
	test_carry_clear	; H=0 N=0 Z=0 V=0 C=0
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	test_h_gr32 byte_dst er0	; er0 contains destination address 
	test_h_gr32 0xa5a5a5a4 er1	; er1 contains test load
	test_gr_a5a5 2		; Make sure other general regs not disturbed
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

	;; Now check the result of the cmp to memory (memory unchanged).
	sub.b	r0l, r0l
	mov.b	@byte_dst, r0l
	cmp.b	#0xa5, r0l
	beq	.L12
	fail
.L12:

cmp_b_rsind_rdind:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#byte_src, er1
	mov	#byte_dst, er2	
	set_ccr_zero
	cmp.b	@er1, @er2
	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	byte_src er1	
	test_h_gr32	byte_dst er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1
.if 1				; ambiguous
cmp_b_rspostinc_rdpostinc:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#byte_src, er1
	mov	#byte_dst, er2	
	set_ccr_zero
	cmp.b	@er1+, @er2+
;;;	.word	0x0174
;;;	.word	0x6c1c
;;;	.word	0x8220

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	byte_src+1 er1	
	test_h_gr32	byte_dst+1 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1
.endif
.if 1				; ambiguous
cmp_b_rspostdec_rdpostdec:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#byte_src, er1
	mov	#byte_dst, er2	
	set_ccr_zero
	cmp.b	@er1-, @er2-
;;;	.word	0x0176
;;;	.word	0x6c1c
;;;	.word	0xa220

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	byte_src-1 er1	
	test_h_gr32	byte_dst-1 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1
.endif

cmp_b_rspreinc_rdpreinc:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#byte_src-1, er1
	mov	#byte_dst-1, er2	
	set_ccr_zero
	cmp.b	@+er1, @+er2
;;;	.word	0x0175
;;;	.word	0x6c1c
;;;	.word	0x9220

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	byte_src er1	
	test_h_gr32	byte_dst er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1

cmp_b_rspredec_predec:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#byte_src+1, er1
	mov	#byte_dst+1, er2	
	set_ccr_zero
	cmp.b	@-er1, @-er2
;;;	.word	0x0177
;;;	.word	0x6c1c
;;;	.word	0xb220

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	byte_src er1	
	test_h_gr32	byte_dst er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1

cmp_b_disp2_disp2:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#byte_src-1, er1
	mov	#byte_dst-2, er2
	set_ccr_zero
	cmp.b	@(1:2, er1), @(2:2, er2)
;;;	.word	0x0175
;;;	.word	0x681c
;;;	.word	0x2220

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	byte_src-1 er1	
	test_h_gr32	byte_dst-2 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1

cmp_b_disp16_disp16:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#byte_src-3, er1
	mov	#byte_dst-4, er2
	set_ccr_zero
	cmp.b	@(3:16, er1), @(4:16, er2)
;;;	.word	0x0174
;;;	.word	0x6e1c
;;;	.word	3
;;;	.word	0xc220
;;;	.word	4

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	byte_src-3 er1	
	test_h_gr32	byte_dst-4 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1

cmp_b_disp32_disp32:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#byte_src+5, er1
	mov	#byte_dst+6, er2
	set_ccr_zero
	cmp.b	@(-5:32, er1), @(-6:32, er2)
;;;	.word	0x7814
;;;	.word	0x6a2c
;;;	.long	-5
;;;	.word	0xca20
;;;	.long	-6

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	byte_src+5 er1	
	test_h_gr32	byte_dst+6 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1

cmp_b_indexb16_indexb16:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#0xffffff01, er1
	mov	#0xffffff02, er2
	set_ccr_zero
	cmp.b	@(byte_src-1:16, r1.b), @(byte_dst-2:16, r2.b)
;;; 	.word	0x0175
;;; 	.word	0x6e1c
;;; 	.word	byte_src-1
;;; 	.word	0xd220
;;; 	.word	byte_dst-2

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	0xffffff01 er1	
	test_h_gr32	0xffffff02 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1
.if 1				; ambiguous
cmp_b_indexw16_indexw16:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#0xffff0003, er1
	mov	#0xffff0004, er2
	set_ccr_zero
	cmp.b	@(byte_src-3:16, r1.w), @(byte_dst-4:16, r2.w)
;;; 	.word	0x0176
;;; 	.word	0x6e1c
;;; 	.word	byte_src-3
;;; 	.word	0xe220
;;; 	.word	byte_dst-4

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	0xffff0003 er1	
	test_h_gr32	0xffff0004 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1
.endif

cmp_b_indexl16_indexl16:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#0x00000005, er1
	mov	#0x00000006, er2
	set_ccr_zero
	cmp.b	@(byte_src-5:16, er1.l), @(byte_dst-6:16, er2.l)
;;; 	.word	0x0177
;;; 	.word	0x6e1c
;;; 	.word	byte_src-5
;;; 	.word	0xf220
;;; 	.word	byte_dst-6

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	0x00000005 er1	
	test_h_gr32	0x00000006 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1

cmp_b_indexb32_indexb32:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#0xffffff01, er1
	mov	#0xffffff02, er2
	set_ccr_zero
	cmp.b	@(byte_src-1:32, r1.b), @(byte_dst-2:32, r2.b)
;;;	.word	0x7815
;;;	.word	0x6a2c
;;;	.long	byte_src-1
;;;	.word	0xda20
;;;	.long	byte_dst-2

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	0xffffff01 er1	
	test_h_gr32	0xffffff02 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1

.if 1				; ambiguous
cmp_b_indexw32_indexw32:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#0xffff0003, er1
	mov	#0xffff0004, er2
	set_ccr_zero
	cmp.b	@(byte_src-3:32, r1.w), @(byte_dst-4:32, r2.w)
;;;	.word	0x7816
;;;	.word	0x6a2c
;;;	.long	byte_src-3
;;;	.word	0xea20
;;;	.long	byte_dst-4

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	0xffff0003 er1	
	test_h_gr32	0xffff0004 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1
.endif

cmp_b_indexl32_indexl32:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	mov	#0x00000005, er1
	mov	#0x00000006, er2
	set_ccr_zero
	cmp.b	@(byte_src-5:32, er1.l), @(byte_dst-6:32, er2.l)
;;;	.word	0x7817
;;;	.word	0x6a2c
;;;	.long	byte_src-5
;;;	.word	0xfa20
;;;	.long	byte_dst-6

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_gr_a5a5	0
	test_h_gr32	0x00000005 er1	
	test_h_gr32	0x00000006 er2
	test_gr_a5a5	3
	test_gr_a5a5	4
	test_gr_a5a5	5
	test_gr_a5a5	6
	test_gr_a5a5	7
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1

cmp_b_abs16_abs16:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero
	cmp.b	@byte_src:16, @byte_dst:16

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_grs_a5a5
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1

cmp_b_abs32_abs32:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero
	cmp.b	@byte_src:32, @byte_dst:32

	test_neg_clear		; N=0, Z=0, V=1, C=0
	test_zero_clear
	test_ovf_set
	test_carry_clear

	test_grs_a5a5
	cmp.b	#0x5a, @byte_src:16
	bne	fail1
	cmp.b	#0xa5, @byte_dst:16
	bne	fail1

.endif
	pass

	exit 0

fail1:	fail