* gas/m68hc11/malis.s: New test to verify compliance with Motorola
[deliverable/binutils-gdb.git] / gas / testsuite / gas / m68hc11 / malis.s
1 ;;
2 ;; This file verifies the compliance with the Motorola specification:
3 ;;
4 ;; MOTOROLA STANDARDS
5 ;; Document #1001, Version 1.0
6 ;; SPECIFICATION FOR Motorola 8- and 16-Bit ASSEMBLY LANGUAGE INPUT STANDARD
7 ;; 26, October 1999
8 ;;
9 ;; Available at:
10 ;;
11 ;; http://www.mcu.motsps.com/dev_tools/hc12/eabi/m8-16alis.pdf
12 ;;
13 ;; Lines starting with '#' represent instructions that fail in GAS.
14 ;;
15 ;;
16 ;; Section 8.2 INPUTS
17 ;; Validated within the whole file
18
19 ;; Section 8.2.1 Character Set
20 ;; TBD
21
22 ;; Section 8.2.2 Assembly Language Statement
23 ;; Validated within the whole file
24
25 ;; Section 8.2.3 Comments
26 ; Motorola comment
27 ;; This file is full of comments
28
29 ;; Section 8.2.5 Location Counter
30 section .text
31
32 _start:
33 L0: * ; L0 set to 0 (relative to text)
34 ldaa 1,x
35 L1: equ * ; L1 set to 2 (relative to text)
36
37 ;; Section 8.2.6 Sections
38 section .data
39 section .text
40 section empty
41 section .text
42
43 ;; Section 8.2.7 Expressions
44 L2: equ 23 ; Absolute = 0x17
45 L3: equ L0-23 ; Simple relocatable
46
47 ;; Section 8.2.7.1 Primary Expression
48 L4: equ 45 ; Numeric = 0x2d
49 L5: equ L0 ; Symbolic
50
51 ;; Section 8.2.7.2 Absolute Expression
52 L_txt: ldaa #44
53 L_txt2:
54 L6: equ -L4 ; unary expr 0xffffffd3
55 L7: equ L6+1000 ; binary expr 0x03bb
56 L8: equ L6-12 ; 0xffffffc7
57 L9: equ L_txt2-L_txt ; reloc - reloc 2 = sizeof(ldaa #44)
58
59 ;; Section 8.2.7.3 Simple Relocatable Expressions
60 L10: equ _start ; symbol 0 + text
61 L11: equ L10+23 ; reloc+abs 0x17 + text
62 L12: equ L11-4 ; reloc-abs 0x13 + text
63 L13: equ L12+L9 ; reloc+abs 0x15 + text
64
65 ;; Section 8.2.8 Symbols
66 section .text
67 Text_Symbol:
68 ldx #Data_Symbol
69
70 section .data
71 Data_Symbol:
72
73 ;; Section 8.2.8.1 Labels
74 L_label_shall_be_significant_to_at_least_32_chars:
75 dc.b 1
76 L_label_lower: ; Labels are case sensitive
77 dc.b 2
78 L_Label_Lower:
79 dc.b 3
80
81 ;; Section 8.2.9 Constants
82 ;
83 ; Section 8.2.9.1 Decimal Constants
84 section .text
85 L_constant:
86 ldaa #123 ; -> ldaa #0x7b
87 ldaa #-23 ; -> ldaa #0xe9
88
89 ;; Section 8.2.9.2 Binary Constants
90 ldab #%10001010 ; -> ldab #0x8A
91 ldab #%0111 ; -> ldab #0x07
92
93 ;; Section 8.2.9.3 Octal Constants
94 ldaa #@74 ; -> ldaa 0x3c
95 ldaa #@377 ; -> ldaa 0xff
96
97 ;; Section 8.2.9.4 Hexadecimal Constants
98 ldaa #$ae ; -> ldaa 0xae
99 ldaa #$B2 ; -> ldaa 0xb2
100
101 ;; Section 8.2.9.5 String Constants
102 section .data
103 # ascii '"Single quote string"'
104 ascii "'Double quote string'"
105
106 ;; Section 8.2.9.6 Floating Point Constants
107 ;; No specification
108 L_float: float 3.241592e-2
109
110 ;; Section 8.2.10 Operators
111 section .text
112 L_operator:
113 ldx #(((1<<3)&(1<<3)|2)<<4)+(4*4-1)
114 ldx #(L2>=23)&1-(L2<=23)&1+(L2==23)&1 ; -> ldx #1
115 ldx #(L2>23)&1-(L2<23)&1+(L2==23)&1 ; -> ldx #0
116 ldx #1-1+1-1+1-1
117 ldab #~L4 ; -> ldab #0xd2
118 # ldab #<_start ; force to 8-bit
119 # ldx #>_start ; force to 16-bit
120 # ldab #page(_start) ; 68HC12 page number of symbol
121
122 ;; Section 8.2.11 Instructions
123 ;; Defined by other tests
124
125 ;; Section 8.2.12 Assembler Directives
126 ;;
127 ;; Section 8.2.12.1 Conditional Directives
128 ;;
129 # The specification says we are allowed to have spaces in expressions.
130 # This does not work with GAS in mri mode, the instruction 'if L2 < 24'
131 # is in fact treated as 'if L2'.
132 L_if:
133 if L2<24 ; true
134 ldx #1 ; -> ldx #1
135 else
136 ldx #2
137 endif
138 if L2<23||L2>23||L2==22+1 ; true
139 if L2<23 ; false
140 ldaa #0
141 endif
142 if L2>23 ; false
143 ldaa #1
144 endif
145 if L2 == 23 ; true
146 ldaa #L2+8 ; -> ldaa #31
147 endif
148 if L2+2<23+2 ; false
149 if L2+4>23+4
150 ldaa #1
151 elseif L2==23
152 ldaa #2
153 else
154 ldaa #3
155 endif
156 elseif L2==23 ; true
157 ldaa #4 ; -> ldaa #4
158 else
159 ldaa #5
160 endif
161 endif
162 ifdef L1 ; true
163 ldx #23 ; -> ldx #0x17
164 endif
165 ifndef L_undef ; true
166 ldx #4 ; -> ldx #4
167 endif
168
169 ;; Section 8.2.12.2 Define Constant -dc
170 section .data
171 L_const_data:
172 dc.b (1<<3)|2 ; 0x0a
173 dc.w (1<<9)+2 ; 0x02 0x02
174 dc.l $12345678
175 dc.b 10
176 dc.l (1<<9)*(3<<12)
177 # dc.b "Hello"
178 # dc.w "World"
179 # dc.l "!!!"
180
181 ;; Section 8.2.12.3 Define Constant Block -dcb
182 dcb.b 3,2
183 dcb.w 2,$55AA
184 dcb.l 2,$12345678
185 dcb.b 10,2
186 dcb.w 5,$55AA
187 dcb.l 2,$12345678
188 # dcb.b 4, 12 ; Fails in GAS due to space
189
190 ;; Section 8.2.12.4 Define Storage - ds
191 ds.b 4
192 ds.w 2
193 ds.l 1
194 ds 2
195
196 ;; Section 8.2.12.5 Equate Symbol Value - equ
197 L_equ1: equ (1<<8)+3
198 L_equ2: equ L_equ1*3
199 L_equ3: equ L_equ2-L_equ1
200
201 ;; Section 8.2.12.6 Include File - include
202 # include 'malis-include.s'
203 # include "malis-include.s"
204 include malis-include.s
205 include malis-include.s
206
207 ;; Section 8.2.12.7 Origin - org
208 section .text
209 # org $100
210 ldaa #23
211 # org $200
212 staa 24
213 # org $0
214 rts
215
216 ;; Section 8.2.12.8 Define Section - section
217 section .text
218 ldaa 23
219
220 section .data
221 dc.b 23
222
223 ;; Section 8.2.12.9 Set Value of Symbol - set
224 s1: set 3
225 s1: set 4
226 s2: set s1+2
227 s3: set s2+4
228
229 ;; Section 8.2.12.10 External Symbol Definition - xdef
230 xdef s1
231 xdef s2
232 xdef entry
233
234 ;; Section 8.2.12.11 External Symbol Reference - xref
235 section .text
236 xref printf
237 xrefb write
238 entry:
239 rts
240
This page took 0.033541 seconds and 4 git commands to generate.