1;;
2;; This file verifies the 68HC12 indexed addressing modes
3;; with a 5, 9 and 16-bit offset.
4;;
5	.sect .text
6	.globl _main
7_main:
8	nop
9;;; Global check (1st)
10	ldab	L1-_main,x	; Offset/const of these 2 insns must be
11	ldaa	#L1-_main	; identical (likewise for 2nd global check)
12;;; Test gas relax with difference of symbols (same section)
13	ldaa	L2-L1,x		; -> ldaa 2,x (5-bit offset), text seg
14	adda	L1-L2,y		; -> adda -2,y (5-bit offset), text seg
15
16	orab	L7-L6,sp	; -> orab 8,sp  (5-bit offset), text seg
17	anda	L8-L7,sp	; -> anda 15,sp (5-bit offset), text seg
18	eora	L7-L8,sp	; -> eora -15,sp (5-bit offset), text seg
19	eorb	L7-L9,sp	; -> eorb -16,sp (5-bit offset), text seg
20
21	andb	L9-L7,sp	; -> andb 16,sp (9-bit offset), text seg
22	staa	L7-L10,x	; -> staa -17,x (9-bit offset), text seg
23	stab	L11-L10,y	; -> stab 128,y (9-bit offset), text seg
24	stab	L10-L11,y	; -> stab -128,y (9-bit offset), text seg
25	stab	L11-L10+1,y	; -> stab 129,y (9-bit offset), text seg
26	stab	L10-L11-1,y	; -> stab -129,y (9-bit offset), text seg
27	stab	L11-1-L10,y	; -> stab 127,y (9-bit offset), text seg
28	stab	L10-1-L11,y	; -> stab -129,y (9-bit offset), text seg
29
30	tst	L12-L10,x	; -> tst 255,x (9-bit offset), text seg
31	tst	L10-L12,x	; -> tst -255,x (9-bit offset), text seg
32	tst	L12-L10+1,x	; -> tst 256,x (16-bit offset), text seg
33	mina	L13-L10,x	; -> mina 256,x (16-bit offset)
34	mina	L10-L13,x	; -> mina -256,x (9-bit offset)
35
36	maxa	L14-L10,x	; -> maxa 257,x (16-bit offset)
37	maxa	L10-L14,x	; -> maxa -257,x (16-bit offset)
38
39;;; Test gas relax with difference of symbols (different section)
40	ldaa	D2-D1,x		; -> ldaa 2,x (5-bit offset), data seg
41	adda	D1-D2,y		; -> adda -2,y (5-bit offset), data seg
42
43	orab	D7-D6,sp	; -> orab 8,sp  (5-bit offset), data seg
44	anda	D8-D7,sp	; -> anda 15,sp (5-bit offset), data seg
45	eora	D7-D8,sp	; -> eora -15,sp (5-bit offset), data seg
46	eorb	D7-D9,sp	; -> eorb -16,sp (5-bit offset), data seg
47
48	andb	D9-D7,sp	; -> andb 16,sp (9-bit offset), data seg
49	staa	D7-D10,x	; -> staa -17,x (9-bit offset), data seg
50	stab	D11-D10,y	; -> stab 128,y (9-bit offset), data seg
51	stab	D10-D11,y	; -> stab -128,y (9-bit offset), data seg
52	stab	D11-D10+1,y	; -> stab 129,y (9-bit offset), data seg
53	stab	D10-D11+1,y	; -> stab -127,y (9-bit offset), data seg
54	stab	D11-1-D10,y	; -> stab 127,y (9-bit offset), data seg
55	stab	D10-1-D11,y	; -> stab -129,y (9-bit offset), data seg
56
57	tst	D12-D10,x	; -> tst 255,x (9-bit offset), data seg
58	tst	D10-D12,x	; -> tst -255,x (9-bit offset), data seg
59	tst	D12-D10+1,x	; -> tst 256,x (16-bit offset), data seg
60	mina	D13-D10,x	; -> mina 256,x (16-bit offset)
61	mina	D10-D13,x	; -> mina -256,x (9-bit offset)
62
63	maxa	D14-D10,x	; -> maxa 257,x (16-bit offset)
64	maxa	D10-D14,x	; -> maxa -257,x (16-bit offset)
65
66;;; Global check (2nd)
67	ldab	L1-_main,x
68	ldaa	#L1-_main
69
70;;; Indexed addressing with external symbol
71	ldab	_external+128,x
72	bra	L2
73L1:
74	.dc.w	0xaabb
75L2:
76L6:
77	.ds.b	8, 0xa7
78L7:
79	.ds.b	15, 0xa7
80L8:
81	nop
82L9:
83	nop
84L10:
85	.skip	128
86L11:
87	.skip	127
88L12:
89	nop
90L13:
91	nop
92L14:
93	rts
94
95	.sect .data
96D1:
97	.dc.w	0xaabb
98D2:
99D6:
100	.ds.b	8, 0xa7
101D7:
102	.ds.b	15, 0xa7
103D8:
104	nop
105D9:
106	nop
107D10:
108	.skip	128
109D11:
110	.skip	127
111D12:
112	nop
113D13:
114	nop
115D14:
116