]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gas/testsuite/gas/m68hc11/m68hc11.exp
.gitignore: ignore .vscode
[thirdparty/binutils-gdb.git] / gas / testsuite / gas / m68hc11 / m68hc11.exp
1 # Copyright (C) 2012-2024 Free Software Foundation, Inc.
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
17 #
18 # Some generic m68HC11 tests
19 #
20 if { ![istarget "m68hc1*-*-*"]
21 && ![istarget "m6811-*-*"]
22 && ![istarget "m6812-*-*"] } then {
23 return
24 }
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
47 gas_m68hc11_opcode_list "-m68hcs12" 192
48 gas_m68hc11_opcode_list "-mm9s12x" 266
49 gas_m68hc11_opcode_list "-mm9s12xg" 74
50
51
52 # Test for a message produced when assembling a file
53 proc gas_m68hc11_message { kind options line expect } {
54 global AS
55 global ASFLAGS
56
57 regsub -all "\n" "$line: $expect" " " title
58
59 # Make a file containing the instructions to assemble.
60 set fd [open "tst-m68hc1x.s" "w"]
61 puts -nonewline $fd "$line"
62 close $fd
63
64 verbose -log "Test: $title"
65 set status [gas_host_run "$AS $ASFLAGS $options tst-m68hc1x.s" ">&gas.out"]
66 set ok 0
67 set fd [open "gas.out" r]
68 while { [gets $fd outline] != -1 } {
69 if { [regexp ".*1: $kind: $expect" $outline] } {
70 incr ok
71 }
72 }
73 if { $ok > 0 } then {
74 pass $title
75 } else {
76 fail $title
77 }
78 catch "exec rm -f tst-m68hc1x.s gas.out"
79 }
80
81 # Test for an error message produced by gas
82 proc gas_m68hc11_error { options line expect } {
83 gas_m68hc11_message "Error" $options $line $expect
84 }
85
86 # Test for a warning message produced by gas
87 proc gas_m68hc11_warning { options line expect } {
88 gas_m68hc11_message "Warning" $options $line $expect
89 }
90
91 # ------------------
92 # 68HC11 error tests
93 gas_m68hc11_error "-m68hc11" "puld\n" "Opcode .puld. is not recognized"
94 gas_m68hc11_error "" "ldab\n" "Invalid operand for .ldab."
95 gas_m68hc11_error "-m68hc11" "ldab 256,x\n" "Operand out of 8-bit range:.*256"
96 gas_m68hc11_error "-m68hc11" "ldab 257,y\n" "Operand out of 8-bit range:.*257"
97 gas_m68hc11_error "-m68hc11" "ldab -1,y\n" "Operand out of 8-bit range:.*-1"
98 gas_m68hc11_error "-m68hc11" "ldab bar,y\nbar=300" "value of 300 too large for field of 1 byte"
99 gas_m68hc11_error "" "jmp \#23\n" "Immediate operand is not allowed"
100 gas_m68hc11_error "-m68hc11" "ldab \[d,pc\]\n" "Indirect indexed addressing is not valid for 68HC11"
101 gas_m68hc11_error "" "ldab ,t\n" "Spurious .,. or bad indirect register"
102 gas_m68hc11_error "" "ldab 1,t\n" "Garbage at end of instruction:.*,t"
103 gas_m68hc11_error "" "ldab 1,,x\n" "Garbage at end of instruction:.*,x"
104 gas_m68hc11_error "-m68hc11" "ldab 1,+x\n" "Pre-increment mode is not valid"
105 gas_m68hc11_error "-m68hc11" "ldab 1,-x\n" "Pre-increment mode is not valid"
106 gas_m68hc11_error "-m68hc11" "ldab 1,x+\n" "Post-increment mode is not valid"
107 gas_m68hc11_error "-m68hc11" "ldab 1,x-\n" "Post-decrement mode is not valid"
108 gas_m68hc11_error "" "ldd \#65536\n" "Operand out of 16-bit range"
109 gas_m68hc11_error "--short-branchs" "bne 200\n" \
110 "Operand out of range for a relative branch"
111 gas_m68hc11_error "" "bar\n" "Opcode .bar. is not recognized."
112 gas_m68hc11_error "--print-insn-syntax" "bne\n" \
113 "Instruction formats for .bne..*"
114 #Check that 9s12x opcodes are rejected
115 gas_m68hc11_error "-m68hc11" "subx\n" "Opcode .subx. is not recognized"
116 gas_m68hc11_error "-m68hc11" "roly\n" "Opcode .roly. is not recognized"
117
118 # ------------------
119 # 68HC12 error tests
120 gas_m68hc11_error "-m68hc12" "ldab x,y\n" "Invalid accumulator register"
121 gas_m68hc11_error "-m68hc12" "ldab \[d,y\n" \
122 "Missing .\]. to close indexed-indirect mode"
123 gas_m68hc11_error "-m68hc12" "ldab 0,\n" "Garbage at end of instruction: .,."
124 gas_m68hc11_error "-m68hc12" "ldab \[d\]\n" \
125 "Missing second register or offset for indexed-indirect mode"
126 gas_m68hc11_error "-m68hc12" "ldab \[d x\]\n" \
127 "Missing second register for indexed-indirect mode"
128 gas_m68hc11_error "-m68hc12" "ldab \[d d\]\n" \
129 "Missing second register for indexed-indirect mode"
130 gas_m68hc11_error "-m68hc12" "ldab \[pc d\]\n" \
131 "Missing second register for indexed-indirect mode"
132 gas_m68hc11_error "-m68hc12" "ldab 65536,x\n" \
133 "Offset out of 16-bit range:"
134 gas_m68hc11_error "-m68hc12 -S" "ibeq d,500\n" \
135 "Operand out of range for a relative branch"
136 gas_m68hc11_error "-m68hc12" "ibeq pc,3\n" \
137 "Invalid register for dbcc/tbcc instruction"
138 gas_m68hc11_error "-m68hc12 -S" "ibeq pc,500\n" \
139 "Invalid register for dbcc/tbcc instruction"
140 gas_m68hc11_error "-m68hc12" "orab 9,+x\n" \
141 "Increment/decrement value is out of range"
142 gas_m68hc11_error "-m68hc12" "orab -9,x-\n" \
143 "Increment/decrement value is out of range"
144 gas_m68hc11_error "-m68hc12" "orab -3,-pc\n" \
145 "Invalid register for post/pre increment"
146 gas_m68hc11_error "-m68hc12" "trap \#0\n" "Trap id .0. is out of range"
147 gas_m68hc11_error "-m68hc12" "trap \#300\n" "Trap id .300. is out of range"
148 gas_m68hc11_error "-m68hc12" "trap \#bar\n" "The trap id must be a constant"
149 gas_m68hc11_error "-m68hc12" "sex x,d\n" \
150 "Invalid source register for this instruction, use .tfr."
151 gas_m68hc11_error "-m68hc12" "tfr pc,a\n" "Invalid source register"
152 gas_m68hc11_error "-m68hc12" "movb 200,x,3,y\n" \
153 "Offset out of 5-bit range for movw/movb insn: 200"
154 gas_m68hc11_error "-m68hc12" "movb 2,x,300,y\n" \
155 "Offset out of 5-bit range for movw/movb insn: 300"
156 gas_m68hc11_error "-m68hc12" "movb 2,x,bar,y\nbar=300\n" \
157 "Offset out of 5-bit range for movw/movb insn: 300"
158 gas_m68hc11_error "-m68hc12" "movb bar,y,2,x\nbar=300\n" \
159 "Offset out of 5-bit range for movw/movb insn: 300"
160 gas_m68hc11_error "-m68hc12" "movb 200,pc,3,y\n" \
161 "Offset out of 5-bit range for movw/movb insn: 200"
162 gas_m68hc11_error "-m68hc12" "movb 2,x,300,pc\n" \
163 "Offset out of 5-bit range for movw/movb insn: 300"
164 gas_m68hc11_error "-m68hc12" "movb 2,x,bar,pc\nbar=300\n" \
165 "Offset out of 5-bit range for movw/movb insn: 300"
166 gas_m68hc11_error "-m68hc12" "movb bar,pc,2,x\nbar=300\n" \
167 "Offset out of 5-bit range for movw/movb insn: 300"
168 #check the 9s12x opcodes not supported
169 gas_m68hc11_error "-m68hc12" "subx\n" "Opcode .subx. is not recognized"
170 gas_m68hc11_error "-m68hc12" "roly\n" "Opcode .roly. is not recognized"
171 gas_m68hc11_error "-m68hc12" "sex d,x\n" \
172 "Invalid source register for this instruction, use .tfr."
173 gas_m68hc11_error "-m68hc12" "sex d,y\n" \
174 "Invalid source register for this instruction, use .tfr."
175
176 #m9s12x tests
177 gas_m68hc11_error "-mm9s12x" "par r3\n" "Opcode .par. is not recognized"
178 gas_m68hc11_error "-mm9s12x" "csem #1\n" "Opcode .csem. is not recognized"
179
180 #m9s12xg tests
181 gas_m68hc11_error "-mm9s12xg" "roly\n" "Opcode .roly. is not recognized"
182 gas_m68hc11_error "-mm9s12xg" "ldab #1\n" "Opcode .ldab. is not recognized"
183
184 # ------------------
185 # Specific commands
186 gas_m68hc11_warning "-m68hc11" ".mode \"bar\"\n" "Invalid mode: .bar."
187 gas_m68hc11_error "-m68hc11" ".relax 23\n" "bad .relax format"
188 gas_m68hc11_error "-m68hc11" ".relax bar-23\n" "bad .relax format"
189 gas_m68hc11_error "-m68hc11" ".far bar bar\n" "junk at end of line"
190
191 run_dump_test insns
192 run_dump_test lbranch
193 run_dump_test all_insns
194 run_dump_test insns-dwarf2
195 run_dump_test lbranch-dwarf2
196 run_dump_test abi-m68hc11-16-64
197 run_dump_test abi-m68hc11-16-32
198 run_dump_test abi-m68hc11-32-64
199
200 # Compliance with Motorola Assembly Language Input Standard
201 run_dump_test malis
202
203 # Some 68HC12 tests
204 run_dump_test opers12
205 run_dump_test opers12-dwarf2
206 run_dump_test branchs12
207 run_dump_test insns12
208 run_dump_test indexed12
209 run_dump_test bug-1825
210 run_dump_test movb
211
212 # Some m9s12x tests
213 run_dump_test insns9s12x
214 run_dump_test 9s12x-exg-sex-tfr
215 run_dump_test 9s12x-mov
216
217 # Some m9s12xg tests
218 run_dump_test insns9s12xg
219
220 # Confirm hex prefixes
221 run_dump_test hexprefix
222