summaryrefslogtreecommitdiff
path: root/sim/testsuite/sim/h8300/neg.s
blob: efb031384dde8267593967b8575f69f3d62f7875 (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
# Hitachi H8 testcase 'neg.b, neg.w, neg.l'
# 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:
	# neg.b rd	;                     1 7 8  rd
	# neg.b @erd	;         7 d rd ???? 1 7 8  ignore
	# neg.b @erd+	; 0 1 7 4 6 c rd 1??? 1 7 8  ignore
	# neg.b @erd-	; 0 1 7 6 6 c rd 1??? 1 7 8  ignore
	# neg.b @+erd	; 0 1 7 5 6 c rd 1??? 1 7 8  ignore
	# neg.b @-erd	; 0 1 7 7 6 c rd 1??? 1 7 8  ignore
	# neg.b @(d:2,  erd)	; 0 1 7 01dd  6 8 rd 8 1 7 8  ignore
	# neg.b @(d:16, erd)	; 0 1 7  4 6 e rd 1??? dd:16 1 7 8  ignore
	# neg.b @(d:32, erd)	; 7 8 rd 4 6 a  2 1??? dd:32 1 7 8  ignore
	# neg.b @aa:16		; 6 a 1 1??? aa:16 1 7 8  ignore
	# neg.b @aa:32		; 6 a 3 1??? aa:32 1 7 8  ignore
	# word operations
	# long operations
	#
	# Coming soon:
	# neg.b @aa:8		; 7 f aaaaaaaa 1 7 8  ignore
	#

	.data
byte_dest:	.byte 0xa5
	.align 2
word_dest:	.word 0xa5a5
	.align 4
long_dest:	.long 0xa5a5a5a5
	start

	#
	# Note:	apparently carry is set for neg of anything except zero.
	#
	
	#
	# 8-bit byte operations 
	#

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

	;;  neg.b Rd
	neg	r0l		; 8-bit register
;;;	.word	0x1788
	
	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear
	
	cmp.b	#0x5b, r0l	; result of "neg 0xa5"
	beq	.Lbrd
	fail
.Lbrd:	
	test_h_gr16 0xa55b r0	; r0 changed by 'neg'
.if (sim_cpu)			; non-zero means h8300h, s, or sx
	test_h_gr32 0xa5a5a55b er0	; er0 changed by 'neg' 
.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)
neg_b_rdind:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  neg.b @eRd
	mov	#byte_dest, er0
	neg.b	@er0		; register indirect operand
;;;	.word	0x7d00
;;;	.word	0x1780

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear
	
	test_h_gr32 byte_dest er0	; er0 still contains address
	cmp.b	#0x5b, @er0	; memory contents changed
	beq	.Lbind
	fail
.Lbind:
	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

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

	;;  neg.b @eRd+
	mov	#byte_dest, er0	; register post-increment operand
	neg.b	@er0+
;;;	.word	0x0174
;;;	.word	0x6c08
;;;	.word	0x1780

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	test_h_gr32 byte_dest+1 er0	; er0 contains address plus one
	cmp.b	#0xa5, @-er0
	beq	.Lbpostinc
	fail
.Lbpostinc:
	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

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

	;;  neg.b @eRd-
	mov	#byte_dest, er0	; register post-decrement operand
	neg.b	@er0-
;;;	.word	0x0176
;;;	.word	0x6c08
;;;	.word	0x1780

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	test_h_gr32 byte_dest-1 er0	; er0 contains address minus one
	cmp.b	#0x5b, @+er0
	beq	.Lbpostdec
	fail
.Lbpostdec:
	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

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

	;;  neg.b @+eRd
	mov	#byte_dest-1, er0
	neg.b	@+er0			; reg pre-increment operand
;;;	.word	0x0175
;;;	.word	0x6c08
;;;	.word	0x1780

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.b	#0xa5, @er0
	beq	.Lbpreinc
	fail
.Lbpreinc:
	test_h_gr32 byte_dest 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

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

	;;  neg.b @-eRd
	mov	#byte_dest+1, er0
	neg.b	@-er0		; reg pre-decr operand
;;;	.word	0x0177
;;;	.word	0x6c08
;;;	.word	0x1780

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.b	#0x5b, @er0
	beq	.Lbpredec
	fail
.Lbpredec:
	test_h_gr32 byte_dest 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

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

	;;  neg.b @(dd:2, erd)
	mov	#byte_dest-1, er0
	neg.b	@(1:2, er0)	; reg plus 2-bit displacement
;;; 	.word	0x0175
;;; 	.word	0x6808
;;; 	.word	0x1780

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.b	#0xa5, @+er0
	beq	.Lbdisp2
	fail
.Lbdisp2:
	test_h_gr32 byte_dest 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

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

	;;  neg.b @(dd:16, erd)
	mov	#byte_dest+100, er0
	neg.b	@(-100:16, er0)	; reg plus 16-bit displacement
;;;	.word	0x0174
;;;	.word	0x6e08
;;;	.word	-100
;;;	.word	0x1780

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.b	#0x5b, @byte_dest
	beq	.Lbdisp16
	fail
.Lbdisp16:
	test_h_gr32 byte_dest+100 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

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

	;;  neg.b @(dd:32, erd)
	mov	#byte_dest-0xfffff, er0
	neg.b	@(0xfffff:32, er0)	; reg plus 32-bit displacement
;;;	.word	0x7804
;;;	.word	0x6a28
;;;	.long	0xfffff
;;;	.word	0x1780

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.b	#0xa5, @byte_dest
	beq	.Lbdisp32
	fail
.Lbdisp32:
	test_h_gr32 byte_dest-0xfffff 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

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

	;;  neg.b @aa:16
	neg.b	@byte_dest:16	; 16-bit absolute address
;;;	.word	0x6a18
;;;	.word	byte_dest
;;;	.word	0x1780

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.b	#0x5b, @byte_dest
	beq	.Lbabs16
	fail
.Lbabs16:
	test_gr_a5a5 0		; Make sure ALL general regs not disturbed
	test_gr_a5a5 1
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

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

	;;  neg.b @aa:32
	neg.b	@byte_dest:32	; 32-bit absolute address
;;;	.word	0x6a38
;;;	.long	byte_dest
;;;	.word	0x1780

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.b	#0xa5, @byte_dest
	beq	.Lbabs32
	fail
.Lbabs32:
	test_gr_a5a5 0		; Make sure ALL general regs not disturbed
	test_gr_a5a5 1
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7
.endif

	#
	# 16-bit word operations
	#

.if (sim_cpu)			; any except plain-vanilla h8/300
neg_w_reg16:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  neg.w Rd
	neg	r1		; 16-bit register operand
;;;	.word	0x1791
	
	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear
	
	cmp.w	#0x5a5b, r1	; result of "neg 0xa5a5"
	beq	.Lwrd
	fail
.Lwrd:	
	test_h_gr32 0xa5a55a5b er1	; er1 changed by 'neg' 
	test_gr_a5a5 0		; 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)
neg_w_rdind:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  neg.w @eRd
	mov	#word_dest, er1
	neg.w	@er1		; register indirect operand
;;;	.word	0x0154
;;;	.word	0x6d18
;;;	.word	0x1790

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.w	#0x5a5b, @word_dest	; memory contents changed
	beq	.Lwind
	fail
.Lwind:
	test_h_gr32 word_dest er1	; er1 still contains address
	test_gr_a5a5 0		; 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

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

	;;  neg.w @eRd+
	mov	#word_dest, er1	; register post-increment operand
	neg.w	@er1+
;;;	.word	0x0154
;;;	.word	0x6d18
;;;	.word	0x1790

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.w	#0xa5a5, @word_dest
	beq	.Lwpostinc
	fail
.Lwpostinc:
	test_h_gr32 word_dest+2 er1	; er1 contains address plus two
	test_gr_a5a5 0		; 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

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

	;;  neg.w @eRd-
	mov	#word_dest, er1
	neg.w	@er1-
;;;	.word	0x0156
;;;	.word	0x6d18
;;;	.word	0x1790

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.w	#0x5a5b, @word_dest
	beq	.Lwpostdec
	fail
.Lwpostdec:
	test_h_gr32 word_dest-2 er1	; er1 contains address minus two
	test_gr_a5a5 0		; 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

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

	;;  neg.w @+eRd
	mov	#word_dest-2, er1
	neg.w	@+er1		; reg pre-increment operand
;;;	.word	0x0155
;;;	.word	0x6d18
;;;	.word	0x1790

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.w	#0xa5a5, @word_dest
	beq	.Lwpreinc
	fail
.Lwpreinc:
	test_h_gr32 word_dest er1	; er1 contains destination address 
	test_gr_a5a5 0		; 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

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

	;;  neg.w @-eRd
	mov	#word_dest+2, er1
	neg.w	@-er1		; reg pre-decr operand
;;;	.word	0x0157
;;;	.word	0x6d18
;;;	.word	0x1790

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.w	#0x5a5b, @word_dest
	beq	.Lwpredec
	fail
.Lwpredec:
	test_h_gr32 word_dest er1	; er1 contains destination address 
	test_gr_a5a5 0		; 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

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

	;;  neg.w @(dd:2, erd)
	mov	#word_dest-1, er1
	neg.w	@(1:2, er1)	; reg plus 2-bit displacement
;;; 	.word	0x0155
;;; 	.word	0x6918
;;; 	.word	0x1790

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.w	#0xa5a5, @word_dest
	beq	.Lwdisp2
	fail
.Lwdisp2:
	test_h_gr32 word_dest-1 er1	; er1 contains address minus one
	test_gr_a5a5 0		; 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

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

	;;  neg.w @(dd:16, erd)
	mov	#word_dest+100, er1
	neg.w	@(-100:16, er1)	; reg plus 16-bit displacement
;;;	.word	0x0154
;;;	.word	0x6f18
;;;	.word	-100
;;;	.word	0x1790

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.w	#0x5a5b, @word_dest
	beq	.Lwdisp16
	fail
.Lwdisp16:
	test_h_gr32 word_dest+100 er1	; er1 contains destination address 
	test_gr_a5a5 0		; 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

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

	;;  neg.w @(dd:32, erd)
	mov	#word_dest-0xfffff, er1
	neg.w	@(0xfffff:32, er1)	; reg plus 32-bit displacement
;;;	.word	0x7814
;;;	.word	0x6b28
;;;	.long	0xfffff
;;;	.word	0x1790

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.w	#0xa5a5, @word_dest
	beq	.Lwdisp32
	fail
.Lwdisp32:
	test_h_gr32 word_dest-0xfffff er1 ; er1 contains destination address
	test_gr_a5a5 0		; 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

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

	;;  neg.w @aa:16
	neg.w	@word_dest:16	; 16-bit absolute address
;;;	.word	0x6b18
;;;	.word	word_dest
;;;	.word	0x1790

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.w	#0x5a5b, @word_dest
	beq	.Lwabs16
	fail
.Lwabs16:
	test_gr_a5a5 0		; Make sure ALL general regs not disturbed
	test_gr_a5a5 1
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

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

	;;  neg.w @aa:32
	neg.w	@word_dest:32	; 32-bit absolute address
;;;	.word	0x6b38
;;;	.long	word_dest
;;;	.word	0x1790

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.w	#0xa5a5, @word_dest
	beq	.Lwabs32
	fail
.Lwabs32:
	test_gr_a5a5 0		; Make sure ALL general regs not disturbed
	test_gr_a5a5 1
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

.endif				; h8sx
.endif				; h8/300

	#
	# 32-bit word operations
	#

.if (sim_cpu)			; any except plain-vanilla h8/300
neg_l_reg16:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  neg.l eRd
	neg	er1		; 32-bit register operand
;;;	.word	0x17b1

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.l	#0x5a5a5a5b, er1	; result of "neg 0xa5a5a5a5"
	beq	.Llrd
	fail
.Llrd:	
	test_h_gr32 0x5a5a5a5b er1	; er1 changed by 'neg' 
	test_gr_a5a5 0		; 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)
neg_l_rdind:
	set_grs_a5a5		; Fill all general regs with a fixed pattern
	set_ccr_zero

	;;  neg.l @eRd
	mov	#long_dest, er1
	neg.l	@er1		; register indirect operand
;;;	.word	0x0104
;;;	.word	0x6d18
;;;	.word	0x17b0

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.l	#0x5a5a5a5b, @long_dest	; memory contents changed
	beq	.Llind
	fail
.Llind:
	test_h_gr32 long_dest er1	; er1 still contains address
	test_gr_a5a5 0		; 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

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

	;;  neg.l @eRd+
	mov	#long_dest, er1	; register post-increment operand
	neg.l	@er1+
;;;	.word	0x0104
;;;	.word	0x6d18
;;;	.word	0x17b0

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.l	#0xa5a5a5a5, @long_dest
	beq	.Llpostinc
	fail
.Llpostinc:
	test_h_gr32 long_dest+4 er1	; er1 contains address plus two
	test_gr_a5a5 0		; 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

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

	;;  neg.l @eRd-
	mov	#long_dest, er1
	neg.l	@er1-
;;;	.word	0x0106
;;;	.word	0x6d18
;;;	.word	0x17b0

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.l	#0x5a5a5a5b, @long_dest
	beq	.Llpostdec
	fail
.Llpostdec:
	test_h_gr32 long_dest-4 er1	; er1 contains address minus two
	test_gr_a5a5 0		; 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

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

	;;  neg.l @+eRd
	mov	#long_dest-4, er1
	neg.l	@+er1		; reg pre-increment operand
;;;	.word	0x0105
;;;	.word	0x6d18
;;;	.word	0x17b0

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.l	#0xa5a5a5a5, @long_dest
	beq	.Llpreinc
	fail
.Llpreinc:
	test_h_gr32 long_dest er1	; er1 contains destination address 
	test_gr_a5a5 0		; 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

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

	;;  neg.l @-eRd
	mov	#long_dest+4, er1
	neg.l	@-er1		; reg pre-decr operand
;;;	.word	0x0107
;;;	.word	0x6d18
;;;	.word	0x17b0

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.l	#0x5a5a5a5b, @long_dest
	beq	.Llpredec
	fail
.Llpredec:
	test_h_gr32 long_dest er1	; er1 contains destination address 
	test_gr_a5a5 0		; 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

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

	;;  neg.l @(dd:2, erd)
	mov	#long_dest-1, er1
	neg.l	@(1:2, er1)	; reg plus 2-bit displacement
;;; 	.word	0x0105
;;; 	.word	0x6918
;;; 	.word	0x17b0

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.l	#0xa5a5a5a5, @long_dest
	beq	.Lldisp2
	fail
.Lldisp2:
	test_h_gr32 long_dest-1 er1	; er1 contains address minus one
	test_gr_a5a5 0		; 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

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

	;;  neg.l @(dd:16, erd)
	mov	#long_dest+100, er1
	neg.l	@(-100:16, er1)	; reg plus 16-bit displacement
;;;	.word	0x0104
;;;	.word	0x6f18
;;;	.word	-100
;;;	.word	0x17b0

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.l	#0x5a5a5a5b, @long_dest
	beq	.Lldisp16
	fail
.Lldisp16:
	test_h_gr32 long_dest+100 er1	; er1 contains destination address 
	test_gr_a5a5 0		; 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

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

	;;  neg.l @(dd:32, erd)
	mov	#long_dest-0xfffff, er1
	neg.l	@(0xfffff:32, er1)	; reg plus 32-bit displacement
;;;	.word	0x7894
;;;	.word	0x6b28
;;;	.long	0xfffff
;;;	.word	0x17b0

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.l	#0xa5a5a5a5, @long_dest
	beq	.Lldisp32
	fail
.Lldisp32:
	test_h_gr32 long_dest-0xfffff er1 ; er1 contains destination address
	test_gr_a5a5 0		; 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

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

	;;  neg.l @aa:16
	neg.l	@long_dest:16	; 16-bit absolute address
;;;	.word	0x0104
;;;	.word	0x6b08
;;;	.word	long_dest
;;;	.word	0x17b0

	test_carry_set		; H=0 N=0 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_clear

	cmp.l	#0x5a5a5a5b, @long_dest
	beq	.Llabs16
	fail
.Llabs16:
	test_gr_a5a5 0		; Make sure ALL general regs not disturbed
	test_gr_a5a5 1
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

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

	;;  neg.l @aa:32
	neg.l	@long_dest:32	; 32-bit absolute address
;;;	.word	0x0104
;;;	.word	0x6b28
;;;	.long	long_dest
;;;	.word	0x17b0

	test_carry_set		; H=0 N=1 Z=0 V=0 C=1
	test_ovf_clear
	test_zero_clear
	test_neg_set

	cmp.l	#0xa5a5a5a5, @long_dest
	beq	.Llabs32
	fail
.Llabs32:
	test_gr_a5a5 0		; Make sure ALL general regs not disturbed
	test_gr_a5a5 1
	test_gr_a5a5 2
	test_gr_a5a5 3
	test_gr_a5a5 4
	test_gr_a5a5 5
	test_gr_a5a5 6
	test_gr_a5a5 7

.endif				; h8sx
.endif				; h8/300

	pass

	exit 0