Home | History | Annotate | Line # | Download | only in h8300
      1  1.1  christos # Hitachi H8 testcase 'ldc'
      2  1.1  christos # mach(): all
      3  1.1  christos # as(h8300):	--defsym sim_cpu=0
      4  1.1  christos # as(h8300h):	--defsym sim_cpu=1
      5  1.1  christos # as(h8300s):	--defsym sim_cpu=2
      6  1.1  christos # as(h8sx):	--defsym sim_cpu=3
      7  1.1  christos # ld(h8300h):	-m h8300helf
      8  1.1  christos # ld(h8300s):	-m h8300self
      9  1.1  christos # ld(h8sx):	-m h8300sxelf
     10  1.1  christos 
     11  1.1  christos 	.include "testutils.inc"
     12  1.1  christos 
     13  1.1  christos 	start
     14  1.1  christos 
     15  1.1  christos .data
     16  1.1  christos 	.align 4
     17  1.1  christos stack:
     18  1.1  christos .if (sim_cpu == h8300)
     19  1.1  christos 	.fill	128, 2, 0
     20  1.1  christos .else
     21  1.1  christos 	.fill	128, 4, 0
     22  1.1  christos .endif
     23  1.1  christos stacktop:
     24  1.1  christos 
     25  1.1  christos 	.text
     26  1.1  christos 
     27  1.1  christos push_w:
     28  1.1  christos 	set_grs_a5a5		; Fill all general regs with a fixed pattern
     29  1.1  christos 	set_ccr_zero
     30  1.1  christos .if (sim_cpu == h8300)
     31  1.1  christos 	mov.w	#stacktop, r7
     32  1.1  christos .else
     33  1.1  christos 	mov.l	#stacktop, er7
     34  1.1  christos .endif
     35  1.1  christos 	push.w	r0		; a5a5 is negative
     36  1.1  christos 	test_neg_set
     37  1.1  christos 	test_carry_clear
     38  1.1  christos 	test_zero_clear
     39  1.1  christos 	test_ovf_clear
     40  1.1  christos 
     41  1.1  christos 	push.w	r1
     42  1.1  christos 	push.w	r2
     43  1.1  christos 	push.w	r3
     44  1.1  christos 
     45  1.1  christos 	test_gr_a5a5 0
     46  1.1  christos 	test_gr_a5a5 1
     47  1.1  christos 	test_gr_a5a5 2
     48  1.1  christos 	test_gr_a5a5 3
     49  1.1  christos 
     50  1.1  christos 	mov	@stacktop-2, r0
     51  1.1  christos 	test_gr_a5a5 0
     52  1.1  christos 	mov	@stacktop-4, r0
     53  1.1  christos 	test_gr_a5a5 0
     54  1.1  christos 	mov	@stacktop-6, r0
     55  1.1  christos 	test_gr_a5a5 0
     56  1.1  christos 	mov	@stacktop-8, r0
     57  1.1  christos 	test_gr_a5a5 0
     58  1.1  christos 
     59  1.1  christos 	mov.w	#1, r1
     60  1.1  christos 	mov.w	#2, r2
     61  1.1  christos 	mov.w	#3, r3
     62  1.1  christos 	mov.w	#4, r4
     63  1.1  christos 
     64  1.1  christos 	push.w	r1		; #1 is non-negative, non-zero
     65  1.1  christos 	test_cc_clear
     66  1.1  christos 
     67  1.1  christos 	push.w	r2
     68  1.1  christos 	push.w	r3
     69  1.1  christos 	push.w	r4
     70  1.1  christos 
     71  1.1  christos 	test_h_gr16 1 r1
     72  1.1  christos 	test_h_gr16 2 r2
     73  1.1  christos 	test_h_gr16 3 r3
     74  1.1  christos 	test_h_gr16 4 r4
     75  1.1  christos 
     76  1.1  christos 	mov	@stacktop-10, r0
     77  1.1  christos 	test_h_gr16 1 r0
     78  1.1  christos 	mov	@stacktop-12, r0
     79  1.1  christos 	test_h_gr16 2 r0
     80  1.1  christos 	mov	@stacktop-14, r0
     81  1.1  christos 	test_h_gr16 3 r0
     82  1.1  christos 	mov	@stacktop-16, r0
     83  1.1  christos 	test_h_gr16 4 r0
     84  1.1  christos 
     85  1.1  christos .if (sim_cpu == h8300)
     86  1.1  christos 	test_h_gr16	4 r0
     87  1.1  christos 	test_h_gr16	1 r1
     88  1.1  christos 	test_h_gr16	2 r2
     89  1.1  christos 	test_h_gr16	3 r3
     90  1.1  christos 	test_h_gr16	4 r4
     91  1.1  christos ;;; 	test_h_gr16	stacktop-16 r7	; FIXME
     92  1.1  christos .else
     93  1.1  christos 	test_h_gr32	0xa5a50004  er0
     94  1.1  christos 	test_h_gr32	0xa5a50001  er1
     95  1.1  christos 	test_h_gr32	0xa5a50002  er2
     96  1.1  christos 	test_h_gr32	0xa5a50003  er3
     97  1.1  christos 	test_h_gr32	0xa5a50004  er4
     98  1.1  christos 	test_h_gr32	stacktop-16 er7
     99  1.1  christos .endif
    100  1.1  christos 	test_gr_a5a5	5
    101  1.1  christos 	test_gr_a5a5	6
    102  1.1  christos 
    103  1.1  christos pop_w:
    104  1.1  christos 	set_grs_a5a5		; Fill all general regs with a fixed pattern
    105  1.1  christos 	set_ccr_zero
    106  1.1  christos .if (sim_cpu == h8300)
    107  1.1  christos 	mov.w	#stacktop-16, r7
    108  1.1  christos .else
    109  1.1  christos 	mov.l	#stacktop-16, er7
    110  1.1  christos .endif
    111  1.1  christos 	pop.w	r4
    112  1.1  christos 	pop.w	r3
    113  1.1  christos 	pop.w	r2
    114  1.1  christos 	pop.w	r1		; Should set all flags zero
    115  1.1  christos 	test_cc_clear
    116  1.1  christos 
    117  1.1  christos 	test_h_gr16	1 r1
    118  1.1  christos 	test_h_gr16	2 r2
    119  1.1  christos 	test_h_gr16	3 r3
    120  1.1  christos 	test_h_gr16	4 r4
    121  1.1  christos 
    122  1.1  christos 	pop.w	r4
    123  1.1  christos 	pop.w	r3
    124  1.1  christos 	pop.w	r2
    125  1.1  christos 	pop.w	r1		; a5a5 is negative
    126  1.1  christos 	test_neg_set
    127  1.1  christos 	test_carry_clear
    128  1.1  christos 	test_zero_clear
    129  1.1  christos 	test_ovf_clear
    130  1.1  christos 
    131  1.1  christos 	test_gr_a5a5	0
    132  1.1  christos 	test_gr_a5a5	1
    133  1.1  christos 	test_gr_a5a5	2
    134  1.1  christos 	test_gr_a5a5	3
    135  1.1  christos 	test_gr_a5a5	4
    136  1.1  christos 	test_gr_a5a5	5
    137  1.1  christos 	test_gr_a5a5	6
    138  1.1  christos .if (sim_cpu == h8300)
    139  1.1  christos ;;; 	test_h_gr16	stacktop r7	; FIXME
    140  1.1  christos .else
    141  1.1  christos 	test_h_gr32	stacktop er7
    142  1.1  christos .endif
    143  1.1  christos 
    144  1.1  christos .if (sim_cpu)			; non-zero means not h8300
    145  1.1  christos push_l:
    146  1.1  christos 	set_grs_a5a5		; Fill all general regs with a fixed pattern
    147  1.1  christos 	set_ccr_zero
    148  1.1  christos 	mov.l	#stacktop, er7
    149  1.1  christos 	push.l	er0		; a5a5 is negative
    150  1.1  christos 	test_neg_set
    151  1.1  christos 	test_carry_clear
    152  1.1  christos 	test_zero_clear
    153  1.1  christos 	test_ovf_clear
    154  1.1  christos 
    155  1.1  christos 	push.l	er1
    156  1.1  christos 	push.l	er2
    157  1.1  christos 	push.l	er3
    158  1.1  christos 
    159  1.1  christos 	test_gr_a5a5 0
    160  1.1  christos 	test_gr_a5a5 1
    161  1.1  christos 	test_gr_a5a5 2
    162  1.1  christos 	test_gr_a5a5 3
    163  1.1  christos 
    164  1.1  christos 	mov	@stacktop-4, er0
    165  1.1  christos 	test_gr_a5a5 0
    166  1.1  christos 	mov	@stacktop-8, er0
    167  1.1  christos 	test_gr_a5a5 0
    168  1.1  christos 	mov	@stacktop-12, er0
    169  1.1  christos 	test_gr_a5a5 0
    170  1.1  christos 	mov	@stacktop-16, er0
    171  1.1  christos 	test_gr_a5a5 0
    172  1.1  christos 
    173  1.1  christos 	mov	#1, er1
    174  1.1  christos 	mov	#2, er2
    175  1.1  christos 	mov	#3, er3
    176  1.1  christos 	mov	#4, er4
    177  1.1  christos 
    178  1.1  christos 	push.l	er1		; #1 is non-negative, non-zero
    179  1.1  christos 	test_cc_clear
    180  1.1  christos 
    181  1.1  christos 	push.l	er2
    182  1.1  christos 	push.l	er3
    183  1.1  christos 	push.l	er4
    184  1.1  christos 
    185  1.1  christos 	test_h_gr32 1 er1
    186  1.1  christos 	test_h_gr32 2 er2
    187  1.1  christos 	test_h_gr32 3 er3
    188  1.1  christos 	test_h_gr32 4 er4
    189  1.1  christos 
    190  1.1  christos 	mov	@stacktop-20, er0
    191  1.1  christos 	test_h_gr32 1 er0
    192  1.1  christos 	mov	@stacktop-24, er0
    193  1.1  christos 	test_h_gr32 2 er0
    194  1.1  christos 	mov	@stacktop-28, er0
    195  1.1  christos 	test_h_gr32 3 er0
    196  1.1  christos 	mov	@stacktop-32, er0
    197  1.1  christos 	test_h_gr32 4 er0
    198  1.1  christos 
    199  1.1  christos 	test_h_gr32	4  er0
    200  1.1  christos 	test_h_gr32	1  er1
    201  1.1  christos 	test_h_gr32	2  er2
    202  1.1  christos 	test_h_gr32	3  er3
    203  1.1  christos 	test_h_gr32	4  er4
    204  1.1  christos 	test_gr_a5a5	5
    205  1.1  christos 	test_gr_a5a5	6
    206  1.1  christos 	test_h_gr32	stacktop-32 er7
    207  1.1  christos 
    208  1.1  christos pop_l:
    209  1.1  christos 	set_grs_a5a5		; Fill all general regs with a fixed pattern
    210  1.1  christos 	set_ccr_zero
    211  1.1  christos 	mov.l	#stacktop-32, er7
    212  1.1  christos 	pop.l	er4
    213  1.1  christos 	pop.l	er3
    214  1.1  christos 	pop.l	er2
    215  1.1  christos 	pop.l	er1		; Should set all flags zero
    216  1.1  christos 	test_cc_clear
    217  1.1  christos 
    218  1.1  christos 	test_h_gr32	1 er1
    219  1.1  christos 	test_h_gr32	2 er2
    220  1.1  christos 	test_h_gr32	3 er3
    221  1.1  christos 	test_h_gr32	4 er4
    222  1.1  christos 
    223  1.1  christos 	pop.l	er4
    224  1.1  christos 	pop.l	er3
    225  1.1  christos 	pop.l	er2
    226  1.1  christos 	pop.l	er1		; a5a5 is negative
    227  1.1  christos 	test_neg_set
    228  1.1  christos 	test_carry_clear
    229  1.1  christos 	test_zero_clear
    230  1.1  christos 	test_ovf_clear
    231  1.1  christos 
    232  1.1  christos 	test_gr_a5a5	0
    233  1.1  christos 	test_gr_a5a5	1
    234  1.1  christos 	test_gr_a5a5	2
    235  1.1  christos 	test_gr_a5a5	3
    236  1.1  christos 	test_gr_a5a5	4
    237  1.1  christos 	test_gr_a5a5	5
    238  1.1  christos 	test_gr_a5a5	6
    239  1.1  christos 	test_h_gr32	stacktop er7
    240  1.1  christos .endif
    241  1.1  christos 
    242  1.1  christos 	;; Jump over subroutine
    243  1.1  christos 	jmp	_bsr
    244  1.1  christos 
    245  1.1  christos bsr_jsr_func:
    246  1.1  christos 	test_ccr 0		; call should not affect ccr
    247  1.1  christos 	mov.w	#0, r0
    248  1.1  christos 	mov.w	#1, r1
    249  1.1  christos 	mov.w	#2, r2
    250  1.1  christos 	mov.w	#3, r3
    251  1.1  christos 	mov.w	#4, r4
    252  1.1  christos 	mov.w	#5, r5
    253  1.1  christos 	mov.w	#6, r6
    254  1.1  christos 	rts
    255  1.1  christos 
    256  1.1  christos _bsr:	set_grs_a5a5
    257  1.1  christos .if (sim_cpu == h8300)
    258  1.1  christos 	mov.w	#stacktop, r7
    259  1.1  christos .else
    260  1.1  christos 	mov.l	#stacktop, er7
    261  1.1  christos .endif
    262  1.1  christos 	set_ccr_zero
    263  1.1  christos 	bsr	bsr_jsr_func
    264  1.1  christos 
    265  1.1  christos 	test_h_gr16	0 r0
    266  1.1  christos 	test_h_gr16	1 r1
    267  1.1  christos 	test_h_gr16	2 r2
    268  1.1  christos 	test_h_gr16	3 r3
    269  1.1  christos 	test_h_gr16	4 r4
    270  1.1  christos 	test_h_gr16	5 r5
    271  1.1  christos 	test_h_gr16	6 r6
    272  1.1  christos .if (sim_cpu == h8300)
    273  1.1  christos ;;; 	test_h_gr16	stacktop, r7	; FIXME
    274  1.1  christos .else
    275  1.1  christos 	test_h_gr32	stacktop, er7
    276  1.1  christos .endif
    277  1.1  christos 
    278  1.1  christos _jsr:	set_grs_a5a5
    279  1.1  christos .if (sim_cpu == h8300)
    280  1.1  christos 	mov.w	#stacktop, r7
    281  1.1  christos .else
    282  1.1  christos 	mov.l	#stacktop, er7
    283  1.1  christos .endif
    284  1.1  christos 	set_ccr_zero
    285  1.1  christos 	jsr	bsr_jsr_func
    286  1.1  christos 
    287  1.1  christos 	test_h_gr16	0 r0
    288  1.1  christos 	test_h_gr16	1 r1
    289  1.1  christos 	test_h_gr16	2 r2
    290  1.1  christos 	test_h_gr16	3 r3
    291  1.1  christos 	test_h_gr16	4 r4
    292  1.1  christos 	test_h_gr16	5 r5
    293  1.1  christos 	test_h_gr16	6 r6
    294  1.1  christos .if (sim_cpu == h8300)
    295  1.1  christos ;;; 	test_h_gr16	stacktop, r7	; FIXME
    296  1.1  christos .else
    297  1.1  christos 	test_h_gr32	stacktop, er7
    298  1.1  christos .endif
    299  1.1  christos 
    300  1.1  christos .if (sim_cpu)			; not zero ie. not h8300
    301  1.1  christos _trapa:
    302  1.1  christos 	set_grs_a5a5
    303  1.1  christos 	mov.l	#trap_handler, er7	; trap vector
    304  1.1  christos 	mov.l	er7, @0x2c
    305  1.1  christos 	mov.l	#stacktop, er7
    306  1.1  christos 	set_ccr_zero
    307  1.1  christos 	trapa	#3
    308  1.1  christos 
    309  1.1  christos 	test_cc_clear		; ccr should be restored by rte
    310  1.1  christos 	test_h_gr16	0x10 r0
    311  1.1  christos 	test_h_gr16	0x11 r1
    312  1.1  christos 	test_h_gr16	0x12 r2
    313  1.1  christos 	test_h_gr16	0x13 r3
    314  1.1  christos 	test_h_gr16	0x14 r4
    315  1.1  christos 	test_h_gr16	0x15 r5
    316  1.1  christos 	test_h_gr16	0x16 r6
    317  1.1  christos 	test_h_gr32	stacktop er7
    318  1.1  christos .endif
    319  1.1  christos 
    320  1.1  christos .if (sim_cpu == h8sx)
    321  1.1  christos _rtsl:				; Test rts/l insn.
    322  1.1  christos 	set_grs_a5a5
    323  1.1  christos 	mov	#0,r0l
    324  1.1  christos 	mov	#1,r1l
    325  1.1  christos 	mov	#2,r2l
    326  1.1  christos 	mov	#3,r3l
    327  1.1  christos 	mov	#4,r4l
    328  1.1  christos 	mov	#5,r5l
    329  1.1  christos 	mov	#6,r6l
    330  1.1  christos 	mov	#stacktop, er7
    331  1.1  christos 
    332  1.1  christos 	jsr	rtsl1_func
    333  1.1  christos 	test_h_gr32	0xa5a5a500 er0
    334  1.1  christos 	test_h_gr32	0xa5a5a501 er1
    335  1.1  christos 	test_h_gr32	0xa5a5a502 er2
    336  1.1  christos 	test_h_gr32	0xa5a5a503 er3
    337  1.1  christos 	test_h_gr32	0xa5a5a504 er4
    338  1.1  christos 	test_h_gr32	0xa5a5a505 er5
    339  1.1  christos 	test_h_gr32	0xa5a5a506 er6
    340  1.1  christos 	test_h_gr32	stacktop   er7
    341  1.1  christos 
    342  1.1  christos 	jsr	rtsl2_func
    343  1.1  christos 	test_h_gr32	0xa5a5a500 er0
    344  1.1  christos 	test_h_gr32	0xa5a5a501 er1
    345  1.1  christos 	test_h_gr32	0xa5a5a502 er2
    346  1.1  christos 	test_h_gr32	0xa5a5a503 er3
    347  1.1  christos 	test_h_gr32	0xa5a5a504 er4
    348  1.1  christos 	test_h_gr32	0xa5a5a505 er5
    349  1.1  christos 	test_h_gr32	0xa5a5a506 er6
    350  1.1  christos 	test_h_gr32	stacktop   er7
    351  1.1  christos 
    352  1.1  christos 	jsr	rtsl3_func
    353  1.1  christos 	test_h_gr32	0xa5a5a500 er0
    354  1.1  christos 	test_h_gr32	0xa5a5a501 er1
    355  1.1  christos 	test_h_gr32	0xa5a5a502 er2
    356  1.1  christos 	test_h_gr32	0xa5a5a503 er3
    357  1.1  christos 	test_h_gr32	0xa5a5a504 er4
    358  1.1  christos 	test_h_gr32	0xa5a5a505 er5
    359  1.1  christos 	test_h_gr32	0xa5a5a506 er6
    360  1.1  christos 	test_h_gr32	stacktop   er7
    361  1.1  christos 
    362  1.1  christos 	jsr	rtsl4_func
    363  1.1  christos 	test_h_gr32	0xa5a5a500 er0
    364  1.1  christos 	test_h_gr32	0xa5a5a501 er1
    365  1.1  christos 	test_h_gr32	0xa5a5a502 er2
    366  1.1  christos 	test_h_gr32	0xa5a5a503 er3
    367  1.1  christos 	test_h_gr32	0xa5a5a504 er4
    368  1.1  christos 	test_h_gr32	0xa5a5a505 er5
    369  1.1  christos 	test_h_gr32	0xa5a5a506 er6
    370  1.1  christos 	test_h_gr32	stacktop   er7
    371  1.1  christos .endif				; h8sx
    372  1.1  christos 
    373  1.1  christos 	pass
    374  1.1  christos 
    375  1.1  christos 	exit 0
    376  1.1  christos 
    377  1.1  christos 	;; Handler for a software exception (trap).
    378  1.1  christos trap_handler:
    379  1.1  christos 	;; Test the 'i' interrupt mask flag.
    380  1.1  christos 	stc	ccr, r0l
    381  1.1  christos 	test_h_gr8	0x80, r0l
    382  1.1  christos 	;; Change the registers (so we know we've been here)
    383  1.1  christos 	mov.w	#0x10, r0
    384  1.1  christos 	mov.w	#0x11, r1
    385  1.1  christos 	mov.w	#0x12, r2
    386  1.1  christos 	mov.w	#0x13, r3
    387  1.1  christos 	mov.w	#0x14, r4
    388  1.1  christos 	mov.w	#0x15, r5
    389  1.1  christos 	mov.w	#0x16, r6
    390  1.1  christos 	;; Change the ccr (which will be restored by RTE)
    391  1.1  christos 	orc	#0xff, ccr
    392  1.1  christos 	rte
    393  1.1  christos 
    394  1.1  christos .if (sim_cpu == h8sx)
    395  1.1  christos 	;; Functions for testing rts/l
    396  1.1  christos rtsl1_func:			; Save and restore R0
    397  1.1  christos 	push.l	er0
    398  1.1  christos 	;; Now modify it, and verify the modification.
    399  1.1  christos 	mov	#0xfeedface, er0
    400  1.1  christos 	test_h_gr32 0xfeedface, er0
    401  1.1  christos 	;; Then use rts/l to restore them and return.
    402  1.1  christos 	rts/l	er0
    403  1.1  christos 
    404  1.1  christos rtsl2_func:			; Save and restore R5 and R6
    405  1.1  christos 	push.l	er5
    406  1.1  christos 	push.l	er6
    407  1.1  christos 	;; Now modify them, and verify the modification.
    408  1.1  christos 	mov	#0xdeadbeef, er5
    409  1.1  christos 	mov	#0xfeedface, er6
    410  1.1  christos 	test_h_gr32 0xdeadbeef, er5
    411  1.1  christos 	test_h_gr32 0xfeedface, er6
    412  1.1  christos 	;; Then use rts/l to restore them and return.
    413  1.1  christos 	rts/l	(er5-er6)
    414  1.1  christos 
    415  1.1  christos rtsl3_func:			; Save and restore R4, R5, and R6
    416  1.1  christos 	push.l	er4
    417  1.1  christos 	push.l	er5
    418  1.1  christos 	push.l	er6
    419  1.1  christos 	;; Now modify them, and verify the modification.
    420  1.1  christos 	mov	#0xdeafcafe, er4
    421  1.1  christos 	mov	#0xdeadbeef, er5
    422  1.1  christos 	mov	#0xfeedface, er6
    423  1.1  christos 	test_h_gr32 0xdeafcafe, er4
    424  1.1  christos 	test_h_gr32 0xdeadbeef, er5
    425  1.1  christos 	test_h_gr32 0xfeedface, er6
    426  1.1  christos 	;; Then use rts/l to restore them and return.
    427  1.1  christos 	rts/l	(er4-er6)
    428  1.1  christos 
    429  1.1  christos rtsl4_func:			; Save and restore R0 - R3
    430  1.1  christos 	push.l	er0
    431  1.1  christos 	push.l	er1
    432  1.1  christos 	push.l	er2
    433  1.1  christos 	push.l	er3
    434  1.1  christos 	;; Now modify them, and verify the modification.
    435  1.1  christos 	mov	#0xdadacafe, er0
    436  1.1  christos 	mov	#0xfeedbeef, er1
    437  1.1  christos 	mov	#0xdeadface, er2
    438  1.1  christos 	mov	#0xf00dd00d, er3
    439  1.1  christos 	test_h_gr32 0xdadacafe, er0
    440  1.1  christos 	test_h_gr32 0xfeedbeef, er1
    441  1.1  christos 	test_h_gr32 0xdeadface, er2
    442  1.1  christos 	test_h_gr32 0xf00dd00d, er3
    443  1.1  christos 	;; Then use rts/l to restore them and return.
    444  1.1  christos 	rts/l	(er0-er3)
    445  1.1  christos .endif				; h8sx
    446