1 # Hitachi H8 testcase 'cmp.b'
3 # as(h8300): --defsym sim_cpu=0
4 # as(h8300h): --defsym sim_cpu=1
5 # as(h8300s): --defsym sim_cpu=2
6 # as(h8sx): --defsym sim_cpu=3
7 # ld(h8300h): -m h8300helf
8 # ld(h8300s): -m h8300self
9 # ld(h8sx): -m h8300sxelf
11 .include "testutils.inc"
13 # Instructions tested:
14 # cmp.b #xx:8, rd ; a rd xxxxxxxx
15 # cmp.b #xx:8, @erd ; 7 d rd ???? a ???? xxxxxxxx
16 # cmp.b #xx:8, @erd+ ; 0 1 7 4 6 c rd 1??? a ???? xxxxxxxx
17 # cmp.b #xx:8, @erd- ; 0 1 7 6 6 c rd 1??? a ???? xxxxxxxx
18 # cmp.b #xx:8, @+erd ; 0 1 7 5 6 c rd 1??? a ???? xxxxxxxx
19 # cmp.b #xx:8, @-erd ; 0 1 7 7 6 c rd 1??? a ???? xxxxxxxx
20 # cmp.b rs, rd ; 1 c rs rd
21 # cmp.b reg8, @erd ; 7 d rd ???? 1 c rs ????
22 # cmp.b reg8, @erd+ ; 0 1 7 9 8 rd 2 rs
23 # cmp.b reg8, @erd- ; 0 1 7 9 a rd 2 rs
24 # cmp.b reg8, @+erd ; 0 1 7 9 9 rd 2 rs
25 # cmp.b reg8, @-erd ; 0 1 7 9 b rd 2 rs
26 # cmp.b rsind, rdind ; 7 c 0rs 5 0 ?rd 2 ????
27 # cmp.b rspostinc, rdpostinc ; 0 1 7 4 6 c 0rs c 8 ?rd 2 ????
28 # cmp.b rspostdec, rdpostdec ; 0 1 7 6 6 c 0rs c a ?rd 2 ????
29 # cmp.b rspreinc, rdpreinc ; 0 1 7 5 6 c 0rs c 9 ?rd 2 ????
30 # cmp.b rspredec, rdpredec ; 0 1 7 7 6 c 0rs c b ?rd 2 ????
31 # cmp.b disp2, disp2 ; 0 1 7 01dd:2 6 8 0rs c 00dd:2 ?rd 2 ????
32 # cmp.b disp16, disp16 ; 0 1 7 4 6 e 0rs c dd:16 c 0rd 2 ???? dd:16
33 # cmp.b disp32, disp32 ; 7 8 0rs 4 6 a 2 c dd:32 c 1rd 2 ???? dd:32
34 # cmp.b indexb16, indexb16 ; 0 1 7 5 6 e 0rs c dd:16 d 0rd 2 ???? dd:16
35 # cmp.b indexw16, indexw16 ; 0 1 7 6 6 e 0rs c dd:16 e 0rd 2 ???? dd:16
36 # cmp.b indexl16, indexl16 ; 0 1 7 7 6 e 0rs c dd:16 f 0rd 2 ???? dd:16
37 # cmp.b indexb32, indexb32 ; 7 8 0rs 5 6 a 2 c dd:32 d 1rd 2 ???? dd:32
38 # cmp.b indexw32, indexw32 ; 7 8 0rs 6 6 a 2 c dd:32 e 1rd 2 ???? dd:32
39 # cmp.b indexl32, indexl32 ; 7 8 0rs 7 6 a 2 c dd:32 f 1rd 2 ???? dd:32
40 # cmp.b abs16, abs16 ; 6 a 1 5 aa:16 4 0??? 2 ???? aa:16
41 # cmp.b abs32, abs32 ; 6 a 3 5 aa:32 4 1??? 2 ???? aa:32
57 set_grs_a5a5 ; Fill all general regs with a fixed pattern
61 cmp.b #0xa5, r0l ; Immediate 8-bit src, reg8 dest
64 .Leq1: cmp.b #0xa6, r0l
67 .Llt1: cmp.b #0xa4, r0l
71 ;; fixme test ccr ; H=0 N=1 Z=0 V=0 C=0
72 test_h_gr16 0xa5a5 r0 ; r0 unchanged
73 .if (sim_cpu) ; non-zero means h8300h, s, or sx
74 test_h_gr32 0xa5a5a5a5 er0 ; er0 unchanged
76 test_gr_a5a5 1 ; Make sure other general regs not disturbed
86 set_grs_a5a5 ; Fill all general regs with a fixed pattern
91 cmp.b #0xa5:8, @er0 ; Immediate 8-bit src, reg indirect dst
109 test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
114 test_h_gr32 byte_dst er0 ; er0 still contains address
115 test_gr_a5a5 1 ; Make sure other general regs not disturbed
123 ;; Now check the result of the cmp to memory (memory unchanged).
131 cmp_b_imm8_rdpostinc:
132 set_grs_a5a5 ; Fill all general regs with a fixed pattern
137 cmp.b #0xa5:8, @er0+ ; Immediate 8-bit src, reg postinc dst
143 .Leq3: test_h_gr32 post_byte er0 ; er0 contains address plus one
152 .Llt3: test_h_gr32 post_byte er0 ; er0 contains address plus one
162 test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
167 test_h_gr32 post_byte er0 ; er0 contains address plus one
168 test_gr_a5a5 1 ; Make sure other general regs not disturbed
176 ;; Now check the result of the cmp to memory (memory unchanged).
184 cmp_b_imm8_rdpostdec:
185 set_grs_a5a5 ; Fill all general regs with a fixed pattern
190 cmp.b #0xa5:8, @er0- ; Immediate 8-bit src, reg postdec dst
196 .Leq4: test_h_gr32 pre_byte er0 ; er0 contains address minus one
205 .Llt4: test_h_gr32 pre_byte er0 ; er0 contains address minus one
215 test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
220 test_h_gr32 pre_byte er0 ; er0 contains address minus one
221 test_gr_a5a5 1 ; Make sure other general regs not disturbed
229 ;; Now check the result of the cmp to memory (memory unchanged).
238 set_grs_a5a5 ; Fill all general regs with a fixed pattern
243 cmp.b #0xa5:8, @+er0 ; Immediate 8-bit src, reg pre-inc dst
249 .Leq5: test_h_gr32 byte_dst er0 ; er0 contains destination address
258 .Llt5: test_h_gr32 byte_dst er0 ; er0 contains destination address
268 test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
273 test_h_gr32 byte_dst er0 ; er0 contains destination address
274 test_gr_a5a5 1 ; Make sure other general regs not disturbed
282 ;; Now check the result of the cmp to memory (memory unchanged).
291 set_grs_a5a5 ; Fill all general regs with a fixed pattern
296 cmp.b #0xa5:8, @-er0 ; Immediate 8-bit src, reg pre-dec dst
302 .Leq6: test_h_gr32 byte_dst er0 ; er0 contains destination address
311 .Llt6: test_h_gr32 byte_dst er0 ; er0 contains destination address
321 test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
326 test_h_gr32 byte_dst er0 ; er0 contains destination address
327 test_gr_a5a5 1 ; Make sure other general regs not disturbed
335 ;; Now check the result of the cmp to memory (memory unchanged).
347 set_grs_a5a5 ; Fill all general regs with a fixed pattern
352 cmp.b r0h, r0l ; Reg8 src, reg8 dst
355 .Leq7: mov.b #0xa6, r0h
359 .Llt7: mov.b #0xa4, r0h
364 ;; fixme test ccr ; H=0 N=1 Z=0 V=0 C=0
365 test_h_gr16 0xa4a5 r0 ; r0l unchanged.
366 .if (sim_cpu) ; non-zero means h8300h, s, or sx
367 test_h_gr32 0xa5a5a4a5 er0 ; r0l unchanged
369 test_gr_a5a5 1 ; Make sure other general regs not disturbed
377 .if (sim_cpu == h8sx)
379 set_grs_a5a5 ; Fill all general regs with a fixed pattern
382 ;; cmp.b rs8,@eRd ; cmp reg8 to register indirect
385 cmp.b r1l, @er0 ; reg8 src, reg indirect dest
405 test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
410 test_h_gr32 byte_dst er0 ; er0 still contains address
411 test_h_gr32 0xa5a5a5a4 er1 ; er1 has the test load
413 test_gr_a5a5 2 ; Make sure other general regs not disturbed
420 ;; Now check the result of the cmp to memory (no change).
428 cmp_b_reg8_rdpostinc:
429 set_grs_a5a5 ; Fill all general regs with a fixed pattern
435 cmp.b r1l, @er0+ ; Immediate 8-bit src, reg post-incr dst
440 .Leq9: test_h_gr32 post_byte er0 ; er0 contains address plus one
449 .Llt9: test_h_gr32 post_byte er0 ; er0 contains address plus one
459 test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
464 test_h_gr32 post_byte er0 ; er0 contains address plus one
465 test_h_gr32 0xa5a5a5a4 er1 ; er1 contains test load
466 test_gr_a5a5 2 ; Make sure other general regs not disturbed
473 ;; Now check the result of the cmp to memory (memory unchanged).
480 ;; special case same register
492 cmp_b_reg8_rdpostdec:
493 set_grs_a5a5 ; Fill all general regs with a fixed pattern
499 cmp.b r1l, @er0- ; Immediate 8-bit src, reg postdec dst
504 .Leq10: test_h_gr32 pre_byte er0 ; er0 contains address minus one
513 .Llt10: test_h_gr32 pre_byte er0 ; er0 contains address minus one
523 test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
528 test_h_gr32 pre_byte er0 ; er0 contains address minus one
529 test_h_gr32 0xa5a5a5a4 er1 ; er1 contains test load
530 test_gr_a5a5 2 ; Make sure other general regs not disturbed
537 ;; Now check the result of the cmp to memory (memory unchanged).
544 ;; special case same register
557 set_grs_a5a5 ; Fill all general regs with a fixed pattern
563 cmp.b r1l, @+er0 ; Immediate 8-bit src, reg post-incr dst
568 .Leq11: test_h_gr32 byte_dst er0 ; er0 contains destination address
577 .Llt11: test_h_gr32 byte_dst er0 ; er0 contains destination address
587 test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
592 test_h_gr32 byte_dst er0 ; er0 contains destination address
593 test_h_gr32 0xa5a5a5a4 er1 ; er1 contains test load
594 test_gr_a5a5 2 ; Make sure other general regs not disturbed
601 ;; Now check the result of the cmp to memory (memory unchanged).
608 ;; special case same register
621 set_grs_a5a5 ; Fill all general regs with a fixed pattern
627 cmp.b r1l, @-er0 ; Immediate 8-bit src, reg postdec dst
632 .Leq12: test_h_gr32 byte_dst er0 ; er0 contains destination address
641 .Llt12: test_h_gr32 byte_dst er0 ; er0 contains destination address
651 test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
656 test_h_gr32 byte_dst er0 ; er0 contains destination address
657 test_h_gr32 0xa5a5a5a4 er1 ; er1 contains test load
658 test_gr_a5a5 2 ; Make sure other general regs not disturbed
665 ;; Now check the result of the cmp to memory (memory unchanged).
672 ;; special case same register
673 mov.l #post_byte, er0
685 set_grs_a5a5 ; Fill all general regs with a fixed pattern
690 test_neg_clear ; N=0, Z=0, V=1, C=0
696 test_h_gr32 byte_src er1
697 test_h_gr32 byte_dst er2
703 cmp.b #0x5a, @byte_src:16
705 cmp.b #0xa5, @byte_dst:16
708 cmp_b_rspostinc_rdpostinc:
709 set_grs_a5a5 ; Fill all general regs with a fixed pattern
718 test_neg_clear ; N=0, Z=0, V=1, C=0
724 test_h_gr32 byte_src+1 er1
725 test_h_gr32 byte_dst+1 er2
731 cmp.b #0x5a, @byte_src:16
733 cmp.b #0xa5, @byte_dst:16
737 cmp_b_rspostdec_rdpostdec:
738 set_grs_a5a5 ; Fill all general regs with a fixed pattern
747 test_neg_clear ; N=0, Z=0, V=1, C=0
753 test_h_gr32 byte_src-1 er1
754 test_h_gr32 byte_dst-1 er2
760 cmp.b #0x5a, @byte_src:16
762 cmp.b #0xa5, @byte_dst:16
766 cmp_b_rspreinc_rdpreinc:
767 set_grs_a5a5 ; Fill all general regs with a fixed pattern
776 test_neg_clear ; N=0, Z=0, V=1, C=0
782 test_h_gr32 byte_src er1
783 test_h_gr32 byte_dst er2
789 cmp.b #0x5a, @byte_src:16
791 cmp.b #0xa5, @byte_dst:16
794 cmp_b_rspredec_predec:
795 set_grs_a5a5 ; Fill all general regs with a fixed pattern
804 test_neg_clear ; N=0, Z=0, V=1, C=0
810 test_h_gr32 byte_src er1
811 test_h_gr32 byte_dst er2
817 cmp.b #0x5a, @byte_src:16
819 cmp.b #0xa5, @byte_dst:16
823 set_grs_a5a5 ; Fill all general regs with a fixed pattern
827 cmp.b @(1:2, er1), @(2:2, er2)
832 test_neg_clear ; N=0, Z=0, V=1, C=0
838 test_h_gr32 byte_src-1 er1
839 test_h_gr32 byte_dst-2 er2
845 cmp.b #0x5a, @byte_src:16
847 cmp.b #0xa5, @byte_dst:16
851 set_grs_a5a5 ; Fill all general regs with a fixed pattern
855 cmp.b @(3:16, er1), @(4:16, er2)
862 test_neg_clear ; N=0, Z=0, V=1, C=0
868 test_h_gr32 byte_src-3 er1
869 test_h_gr32 byte_dst-4 er2
875 cmp.b #0x5a, @byte_src:16
877 cmp.b #0xa5, @byte_dst:16
881 set_grs_a5a5 ; Fill all general regs with a fixed pattern
885 cmp.b @(-5:32, er1), @(-6:32, er2)
892 test_neg_clear ; N=0, Z=0, V=1, C=0
898 test_h_gr32 byte_src+5 er1
899 test_h_gr32 byte_dst+6 er2
905 cmp.b #0x5a, @byte_src:16
907 cmp.b #0xa5, @byte_dst:16
910 cmp_b_indexb16_indexb16:
911 set_grs_a5a5 ; Fill all general regs with a fixed pattern
915 cmp.b @(byte_src-1:16, r1.b), @(byte_dst-2:16, r2.b)
922 test_neg_clear ; N=0, Z=0, V=1, C=0
928 test_h_gr32 0xffffff01 er1
929 test_h_gr32 0xffffff02 er2
935 cmp.b #0x5a, @byte_src:16
937 cmp.b #0xa5, @byte_dst:16
940 cmp_b_indexw16_indexw16:
941 set_grs_a5a5 ; Fill all general regs with a fixed pattern
945 cmp.b @(byte_src-3:16, r1.w), @(byte_dst-4:16, r2.w)
952 test_neg_clear ; N=0, Z=0, V=1, C=0
958 test_h_gr32 0xffff0003 er1
959 test_h_gr32 0xffff0004 er2
965 cmp.b #0x5a, @byte_src:16
967 cmp.b #0xa5, @byte_dst:16
971 cmp_b_indexl16_indexl16:
972 set_grs_a5a5 ; Fill all general regs with a fixed pattern
976 cmp.b @(byte_src-5:16, er1.l), @(byte_dst-6:16, er2.l)
983 test_neg_clear ; N=0, Z=0, V=1, C=0
989 test_h_gr32 0x00000005 er1
990 test_h_gr32 0x00000006 er2
996 cmp.b #0x5a, @byte_src:16
998 cmp.b #0xa5, @byte_dst:16
1001 cmp_b_indexb32_indexb32:
1002 set_grs_a5a5 ; Fill all general regs with a fixed pattern
1003 mov #0xffffff01, er1
1004 mov #0xffffff02, er2
1006 cmp.b @(byte_src-1:32, r1.b), @(byte_dst-2:32, r2.b)
1009 ;;; .long byte_src-1
1011 ;;; .long byte_dst-2
1013 test_neg_clear ; N=0, Z=0, V=1, C=0
1019 test_h_gr32 0xffffff01 er1
1020 test_h_gr32 0xffffff02 er2
1026 cmp.b #0x5a, @byte_src:16
1028 cmp.b #0xa5, @byte_dst:16
1032 cmp_b_indexw32_indexw32:
1033 set_grs_a5a5 ; Fill all general regs with a fixed pattern
1034 mov #0xffff0003, er1
1035 mov #0xffff0004, er2
1037 cmp.b @(byte_src-3:32, r1.w), @(byte_dst-4:32, r2.w)
1040 ;;; .long byte_src-3
1042 ;;; .long byte_dst-4
1044 test_neg_clear ; N=0, Z=0, V=1, C=0
1050 test_h_gr32 0xffff0003 er1
1051 test_h_gr32 0xffff0004 er2
1057 cmp.b #0x5a, @byte_src:16
1059 cmp.b #0xa5, @byte_dst:16
1063 cmp_b_indexl32_indexl32:
1064 set_grs_a5a5 ; Fill all general regs with a fixed pattern
1065 mov #0x00000005, er1
1066 mov #0x00000006, er2
1068 cmp.b @(byte_src-5:32, er1.l), @(byte_dst-6:32, er2.l)
1071 ;;; .long byte_src-5
1073 ;;; .long byte_dst-6
1075 test_neg_clear ; N=0, Z=0, V=1, C=0
1081 test_h_gr32 0x00000005 er1
1082 test_h_gr32 0x00000006 er2
1088 cmp.b #0x5a, @byte_src:16
1090 cmp.b #0xa5, @byte_dst:16
1094 set_grs_a5a5 ; Fill all general regs with a fixed pattern
1096 cmp.b @byte_src:16, @byte_dst:16
1098 test_neg_clear ; N=0, Z=0, V=1, C=0
1104 cmp.b #0x5a, @byte_src:16
1106 cmp.b #0xa5, @byte_dst:16
1110 set_grs_a5a5 ; Fill all general regs with a fixed pattern
1112 cmp.b @byte_src:32, @byte_dst:32
1114 test_neg_clear ; N=0, Z=0, V=1, C=0
1120 cmp.b #0x5a, @byte_src:16
1122 cmp.b #0xa5, @byte_dst:16