Commit | Line | Data |
---|---|---|
6f2750fe | 1 | # Copyright (C) 2012-2016 Free Software Foundation, Inc. |
5bf135a7 NC |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program; if not, write to the Free Software | |
15 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. | |
16 | ||
60bcf0fa NC |
17 | # |
18 | # Some generic m68HC11 tests | |
19 | # | |
017761ea AM |
20 | if { ![istarget "m68hc1*-*-*"] |
21 | && ![istarget "m6811-*-*"] | |
22 | && ![istarget "m6812-*-*"] } then { | |
23 | return | |
60bcf0fa | 24 | } |
f39f5da9 SC |
25 | |
26 | # Simple test for --print-opcodes (list of supported opcodes) | |
27 | # We don't check the list result but just the syntax and the | |
28 | # number it | |
29 | proc gas_m68hc11_opcode_list { flags expect_count } { | |
30 | global comp_output | |
31 | ||
32 | set testname "Opcode list generation \[$flags\]" | |
33 | gas_run "x.s" "--print-opcodes $flags" "" | |
34 | ||
35 | set lines [split $comp_output "\n"] | |
36 | set cnt [llength $lines] | |
37 | verbose -log "Found $cnt opcodes" | |
38 | if { $cnt == $expect_count } then { | |
39 | pass $testname | |
40 | } else { | |
41 | fail $testname | |
42 | } | |
43 | } | |
44 | ||
45 | gas_m68hc11_opcode_list "-m68hc11" 149 | |
46 | gas_m68hc11_opcode_list "-m68hc12" 192 | |
586b12ad | 47 | gas_m68hc11_opcode_list "-m68hcs12" 192 |
6927f982 NC |
48 | gas_m68hc11_opcode_list "-mm9s12x" 266 |
49 | gas_m68hc11_opcode_list "-mm9s12xg" 74 | |
f39f5da9 SC |
50 | |
51 | ||
52 | # Test for a message produced when assembling a file | |
53 | proc gas_m68hc11_message { kind options line expect } { | |
54 | global srcdir | |
55 | global subdir | |
56 | ||
57 | regsub -all "\n" "$line: $expect" " " title | |
58 | ||
59 | # Make a file containing the instructions to assemble. | |
c0b22597 | 60 | set fd [open "$srcdir/$subdir/tst-m68hc1x.s" "w"] |
f39f5da9 SC |
61 | puts -nonewline $fd "$line" |
62 | close $fd | |
63 | ||
64 | verbose -log "Test: $title" | |
65 | gas_start "tst-m68hc1x.s" "$options" | |
66 | set ok 0 | |
67 | while 1 { | |
68 | expect { | |
69 | -re ".*: Assembler messages:\n" { } | |
70 | -re ".*1: $kind: $expect" { incr ok; break } | |
71 | timeout { perror "timeout\n"; break } | |
72 | eof { verbose "EOF from gas"; break } | |
73 | } | |
74 | } | |
75 | #sleep 1 # Uncomment this line when using gcov | |
76 | gas_finish | |
77 | if { $ok > 0 } then { | |
78 | pass $title | |
79 | } else { | |
80 | fail $title | |
81 | } | |
82 | catch "exec rm -f $srcdir/$subdir/tst-m68hc1x.s" | |
83 | } | |
84 | ||
85 | # Test for an error message produced by gas | |
86 | proc gas_m68hc11_error { options line expect } { | |
87 | gas_m68hc11_message "Error" $options $line $expect | |
88 | } | |
89 | ||
90 | # Test for a warning message produced by gas | |
91 | proc gas_m68hc11_warning { options line expect } { | |
92 | gas_m68hc11_message "Warning" $options $line $expect | |
93 | } | |
94 | ||
95 | # ------------------ | |
96 | # 68HC11 error tests | |
017761ea | 97 | gas_m68hc11_error "-m68hc11" "puld\n" "Opcode .puld. is not recognized" |
f39f5da9 | 98 | gas_m68hc11_error "" "ldab\n" "Invalid operand for .ldab." |
017761ea AM |
99 | gas_m68hc11_error "-m68hc11" "ldab 256,x\n" "Operand out of 8-bit range:.*256" |
100 | gas_m68hc11_error "-m68hc11" "ldab 257,y\n" "Operand out of 8-bit range:.*257" | |
101 | gas_m68hc11_error "-m68hc11" "ldab -1,y\n" "Operand out of 8-bit range:.*-1" | |
102 | gas_m68hc11_error "-m68hc11" "ldab bar,y\nbar=300" "value of 300 too large for field of 1 byte" | |
f39f5da9 | 103 | gas_m68hc11_error "" "jmp \#23\n" "Immediate operand is not allowed" |
017761ea | 104 | gas_m68hc11_error "-m68hc11" "ldab \[d,pc\]\n" "Indirect indexed addressing is not valid for 68HC11" |
f39f5da9 SC |
105 | gas_m68hc11_error "" "ldab ,t\n" "Spurious .,. or bad indirect register" |
106 | gas_m68hc11_error "" "ldab 1,t\n" "Garbage at end of instruction:.*,t" | |
107 | gas_m68hc11_error "" "ldab 1,,x\n" "Garbage at end of instruction:.*,x" | |
017761ea AM |
108 | gas_m68hc11_error "-m68hc11" "ldab 1,+x\n" "Pre-increment mode is not valid" |
109 | gas_m68hc11_error "-m68hc11" "ldab 1,-x\n" "Pre-increment mode is not valid" | |
110 | gas_m68hc11_error "-m68hc11" "ldab 1,x+\n" "Post-increment mode is not valid" | |
111 | gas_m68hc11_error "-m68hc11" "ldab 1,x-\n" "Post-decrement mode is not valid" | |
f39f5da9 SC |
112 | gas_m68hc11_error "" "ldd \#65536\n" "Operand out of 16-bit range" |
113 | gas_m68hc11_error "--short-branchs" "bne 200\n" \ | |
114 | "Operand out of range for a relative branch" | |
115 | gas_m68hc11_error "" "bar\n" "Opcode .bar. is not recognized." | |
116 | gas_m68hc11_error "--print-insn-syntax" "bne\n" \ | |
117 | "Instruction formats for .bne..*" | |
6927f982 NC |
118 | #Check that 9s12x opcodes are rejected |
119 | gas_m68hc11_error "-m68hc11" "subx\n" "Opcode .subx. is not recognized" | |
120 | gas_m68hc11_error "-m68hc11" "roly\n" "Opcode .roly. is not recognized" | |
f39f5da9 SC |
121 | |
122 | # ------------------ | |
123 | # 68HC12 error tests | |
124 | gas_m68hc11_error "-m68hc12" "ldab x,y\n" "Invalid accumulator register" | |
125 | gas_m68hc11_error "-m68hc12" "ldab \[d,y\n" \ | |
126 | "Missing .\]. to close indexed-indirect mode" | |
127 | gas_m68hc11_error "-m68hc12" "ldab 0,\n" "Garbage at end of instruction: .,." | |
128 | gas_m68hc11_error "-m68hc12" "ldab \[d\]\n" \ | |
129 | "Missing second register or offset for indexed-indirect mode" | |
130 | gas_m68hc11_error "-m68hc12" "ldab \[d x\]\n" \ | |
131 | "Missing second register for indexed-indirect mode" | |
132 | gas_m68hc11_error "-m68hc12" "ldab \[d d\]\n" \ | |
133 | "Missing second register for indexed-indirect mode" | |
134 | gas_m68hc11_error "-m68hc12" "ldab \[pc d\]\n" \ | |
135 | "Missing second register for indexed-indirect mode" | |
136 | gas_m68hc11_error "-m68hc12" "ldab 65536,x\n" \ | |
137 | "Offset out of 16-bit range:" | |
138 | gas_m68hc11_error "-m68hc12 -S" "ibeq d,500\n" \ | |
139 | "Operand out of range for a relative branch" | |
140 | gas_m68hc11_error "-m68hc12" "ibeq pc,3\n" \ | |
141 | "Invalid register for dbcc/tbcc instruction" | |
142 | gas_m68hc11_error "-m68hc12 -S" "ibeq pc,500\n" \ | |
143 | "Invalid register for dbcc/tbcc instruction" | |
144 | gas_m68hc11_error "-m68hc12" "orab 9,+x\n" \ | |
145 | "Increment/decrement value is out of range" | |
146 | gas_m68hc11_error "-m68hc12" "orab -9,x-\n" \ | |
147 | "Increment/decrement value is out of range" | |
148 | gas_m68hc11_error "-m68hc12" "orab -3,-pc\n" \ | |
149 | "Invalid register for post/pre increment" | |
150 | gas_m68hc11_error "-m68hc12" "trap \#0\n" "Trap id .0. is out of range" | |
151 | gas_m68hc11_error "-m68hc12" "trap \#300\n" "Trap id .300. is out of range" | |
152 | gas_m68hc11_error "-m68hc12" "trap \#bar\n" "The trap id must be a constant" | |
153 | gas_m68hc11_error "-m68hc12" "sex x,d\n" \ | |
154 | "Invalid source register for this instruction, use .tfr." | |
155 | gas_m68hc11_error "-m68hc12" "tfr pc,a\n" "Invalid source register" | |
156 | gas_m68hc11_error "-m68hc12" "movb 200,x,3,y\n" \ | |
157 | "Offset out of 5-bit range for movw/movb insn: 200" | |
158 | gas_m68hc11_error "-m68hc12" "movb 2,x,300,y\n" \ | |
159 | "Offset out of 5-bit range for movw/movb insn: 300" | |
28d39d1a NC |
160 | gas_m68hc11_error "-m68hc12" "movb 2,x,bar,y\nbar=300\n" \ |
161 | "Offset out of 5-bit range for movw/movb insn: 300" | |
162 | gas_m68hc11_error "-m68hc12" "movb bar,y,2,x\nbar=300\n" \ | |
163 | "Offset out of 5-bit range for movw/movb insn: 300" | |
164 | gas_m68hc11_error "-m68hc12" "movb 200,pc,3,y\n" \ | |
165 | "Offset out of 5-bit range for movw/movb insn: 200" | |
166 | gas_m68hc11_error "-m68hc12" "movb 2,x,300,pc\n" \ | |
167 | "Offset out of 5-bit range for movw/movb insn: 300" | |
168 | gas_m68hc11_error "-m68hc12" "movb 2,x,bar,pc\nbar=300\n" \ | |
169 | "Offset out of 5-bit range for movw/movb insn: 300" | |
170 | gas_m68hc11_error "-m68hc12" "movb bar,pc,2,x\nbar=300\n" \ | |
171 | "Offset out of 5-bit range for movw/movb insn: 300" | |
6927f982 NC |
172 | #check the 9s12x opcodes not supported |
173 | gas_m68hc11_error "-m68hc12" "subx\n" "Opcode .subx. is not recognized" | |
174 | gas_m68hc11_error "-m68hc12" "roly\n" "Opcode .roly. is not recognized" | |
175 | gas_m68hc11_error "-m68hc12" "sex d,x\n" \ | |
176 | "Invalid source register for this instruction, use .tfr." | |
177 | gas_m68hc11_error "-m68hc12" "sex d,y\n" \ | |
178 | "Invalid source register for this instruction, use .tfr." | |
179 | ||
180 | #m9s12x tests | |
181 | gas_m68hc11_error "-mm9s12x" "par r3\n" "Opcode .par. is not recognized" | |
182 | gas_m68hc11_error "-mm9s12x" "csem #1\n" "Opcode .csem. is not recognized" | |
183 | ||
184 | #m9s12xg tests | |
185 | gas_m68hc11_error "-mm9s12xg" "roly\n" "Opcode .roly. is not recognized" | |
186 | gas_m68hc11_error "-mm9s12xg" "ldab #1\n" "Opcode .ldab. is not recognized" | |
f39f5da9 SC |
187 | |
188 | # ------------------ | |
189 | # Specific commands | |
6927f982 NC |
190 | gas_m68hc11_warning "-m68hc11" ".mode \"bar\"\n" "Invalid mode: .bar." |
191 | gas_m68hc11_error "-m68hc11" ".relax 23\n" "bad .relax format" | |
192 | gas_m68hc11_error "-m68hc11" ".relax bar-23\n" "bad .relax format" | |
193 | gas_m68hc11_error "-m68hc11" ".far bar bar\n" "junk at end of line" | |
f39f5da9 | 194 | |
60bcf0fa NC |
195 | run_dump_test insns |
196 | run_dump_test lbranch | |
197 | run_dump_test all_insns | |
68a581b8 SC |
198 | run_dump_test insns-dwarf2 |
199 | run_dump_test lbranch-dwarf2 | |
586b12ad SC |
200 | run_dump_test abi-m68hc11-16-64 |
201 | run_dump_test abi-m68hc11-16-32 | |
202 | run_dump_test abi-m68hc11-32-64 | |
60bcf0fa | 203 | |
4f69f974 SC |
204 | # Compliance with Motorola Assembly Language Input Standard |
205 | run_dump_test malis | |
206 | ||
60bcf0fa NC |
207 | # Some 68HC12 tests |
208 | run_dump_test opers12 | |
cd2b2939 SC |
209 | run_dump_test opers12-dwarf2 |
210 | run_dump_test branchs12 | |
211 | run_dump_test insns12 | |
27bdea3d SC |
212 | run_dump_test indexed12 |
213 | run_dump_test bug-1825 | |
28d39d1a | 214 | run_dump_test movb |
6927f982 NC |
215 | |
216 | # Some m9s12x tests | |
217 | run_dump_test insns9s12x | |
218 | run_dump_test 9s12x-exg-sex-tfr | |
219 | run_dump_test 9s12x-mov | |
220 | ||
221 | # Some m9s12xg tests | |
222 | run_dump_test insns9s12xg | |
223 | ||
224 | # Confirm hex prefixes | |
225 | run_dump_test hexprefix | |
226 |