Commit | Line | Data |
---|---|---|
60bcf0fa NC |
1 | # |
2 | # Some generic m68HC11 tests | |
3 | # | |
4 | if ![istarget "m68hc11-*-*"] then { | |
5 | if ![istarget "m6811-*-*"] then { | |
6 | if ![istarget "m68hc12-*-*"] then { | |
7 | if ![istarget "m6812-*-*"] then { | |
8 | return | |
9 | } | |
10 | } | |
11 | } | |
12 | } | |
f39f5da9 SC |
13 | |
14 | # Simple test for --print-opcodes (list of supported opcodes) | |
15 | # We don't check the list result but just the syntax and the | |
16 | # number it | |
17 | proc gas_m68hc11_opcode_list { flags expect_count } { | |
18 | global comp_output | |
19 | ||
20 | set testname "Opcode list generation \[$flags\]" | |
21 | gas_run "x.s" "--print-opcodes $flags" "" | |
22 | ||
23 | set lines [split $comp_output "\n"] | |
24 | set cnt [llength $lines] | |
25 | verbose -log "Found $cnt opcodes" | |
26 | if { $cnt == $expect_count } then { | |
27 | pass $testname | |
28 | } else { | |
29 | fail $testname | |
30 | } | |
31 | } | |
32 | ||
33 | gas_m68hc11_opcode_list "-m68hc11" 149 | |
34 | gas_m68hc11_opcode_list "-m68hc12" 192 | |
586b12ad | 35 | gas_m68hc11_opcode_list "-m68hcs12" 192 |
f39f5da9 SC |
36 | |
37 | ||
38 | # Test for a message produced when assembling a file | |
39 | proc gas_m68hc11_message { kind options line expect } { | |
40 | global srcdir | |
41 | global subdir | |
42 | ||
43 | regsub -all "\n" "$line: $expect" " " title | |
44 | ||
45 | # Make a file containing the instructions to assemble. | |
46 | set fd [open "$srcdir/$subdir/tst-m68hc1x.s" "w"]; | |
47 | puts -nonewline $fd "$line" | |
48 | close $fd | |
49 | ||
50 | verbose -log "Test: $title" | |
51 | gas_start "tst-m68hc1x.s" "$options" | |
52 | set ok 0 | |
53 | while 1 { | |
54 | expect { | |
55 | -re ".*: Assembler messages:\n" { } | |
56 | -re ".*1: $kind: $expect" { incr ok; break } | |
57 | timeout { perror "timeout\n"; break } | |
58 | eof { verbose "EOF from gas"; break } | |
59 | } | |
60 | } | |
61 | #sleep 1 # Uncomment this line when using gcov | |
62 | gas_finish | |
63 | if { $ok > 0 } then { | |
64 | pass $title | |
65 | } else { | |
66 | fail $title | |
67 | } | |
68 | catch "exec rm -f $srcdir/$subdir/tst-m68hc1x.s" | |
69 | } | |
70 | ||
71 | # Test for an error message produced by gas | |
72 | proc gas_m68hc11_error { options line expect } { | |
73 | gas_m68hc11_message "Error" $options $line $expect | |
74 | } | |
75 | ||
76 | # Test for a warning message produced by gas | |
77 | proc gas_m68hc11_warning { options line expect } { | |
78 | gas_m68hc11_message "Warning" $options $line $expect | |
79 | } | |
80 | ||
81 | # ------------------ | |
82 | # 68HC11 error tests | |
83 | gas_m68hc11_error "" "puld\n" "Opcode .puld. is not recognized" | |
84 | gas_m68hc11_error "" "ldab\n" "Invalid operand for .ldab." | |
85 | gas_m68hc11_error "" "ldab 256,x\n" "Operand out of 8-bit range:.*256" | |
86 | gas_m68hc11_error "" "ldab 257,y\n" "Operand out of 8-bit range:.*257" | |
87 | gas_m68hc11_error "" "ldab -1,y\n" "Operand out of 8-bit range:.*-1" | |
88 | gas_m68hc11_error "" "ldab bar,y\nbar=300" "value of 300 too large for field of 1 byte" | |
89 | gas_m68hc11_error "" "jmp \#23\n" "Immediate operand is not allowed" | |
90 | gas_m68hc11_error "" "ldab \[d,pc\]\n" "Indirect indexed addressing is not valid for 68HC11" | |
91 | gas_m68hc11_error "" "ldab ,t\n" "Spurious .,. or bad indirect register" | |
92 | gas_m68hc11_error "" "ldab 1,t\n" "Garbage at end of instruction:.*,t" | |
93 | gas_m68hc11_error "" "ldab 1,,x\n" "Garbage at end of instruction:.*,x" | |
94 | gas_m68hc11_error "" "ldab 1,+x\n" "Pre-increment mode is not valid" | |
95 | gas_m68hc11_error "" "ldab 1,-x\n" "Pre-increment mode is not valid" | |
96 | gas_m68hc11_error "" "ldab 1,x+\n" "Post-increment mode is not valid" | |
97 | gas_m68hc11_error "" "ldab 1,x-\n" "Post-decrement mode is not valid" | |
98 | gas_m68hc11_error "" "ldd \#65536\n" "Operand out of 16-bit range" | |
99 | gas_m68hc11_error "--short-branchs" "bne 200\n" \ | |
100 | "Operand out of range for a relative branch" | |
101 | gas_m68hc11_error "" "bar\n" "Opcode .bar. is not recognized." | |
102 | gas_m68hc11_error "--print-insn-syntax" "bne\n" \ | |
103 | "Instruction formats for .bne..*" | |
104 | ||
105 | # ------------------ | |
106 | # 68HC12 error tests | |
107 | gas_m68hc11_error "-m68hc12" "ldab x,y\n" "Invalid accumulator register" | |
108 | gas_m68hc11_error "-m68hc12" "ldab \[d,y\n" \ | |
109 | "Missing .\]. to close indexed-indirect mode" | |
110 | gas_m68hc11_error "-m68hc12" "ldab 0,\n" "Garbage at end of instruction: .,." | |
111 | gas_m68hc11_error "-m68hc12" "ldab \[d\]\n" \ | |
112 | "Missing second register or offset for indexed-indirect mode" | |
113 | gas_m68hc11_error "-m68hc12" "ldab \[d x\]\n" \ | |
114 | "Missing second register for indexed-indirect mode" | |
115 | gas_m68hc11_error "-m68hc12" "ldab \[d d\]\n" \ | |
116 | "Missing second register for indexed-indirect mode" | |
117 | gas_m68hc11_error "-m68hc12" "ldab \[pc d\]\n" \ | |
118 | "Missing second register for indexed-indirect mode" | |
119 | gas_m68hc11_error "-m68hc12" "ldab 65536,x\n" \ | |
120 | "Offset out of 16-bit range:" | |
121 | gas_m68hc11_error "-m68hc12 -S" "ibeq d,500\n" \ | |
122 | "Operand out of range for a relative branch" | |
123 | gas_m68hc11_error "-m68hc12" "ibeq pc,3\n" \ | |
124 | "Invalid register for dbcc/tbcc instruction" | |
125 | gas_m68hc11_error "-m68hc12 -S" "ibeq pc,500\n" \ | |
126 | "Invalid register for dbcc/tbcc instruction" | |
127 | gas_m68hc11_error "-m68hc12" "orab 9,+x\n" \ | |
128 | "Increment/decrement value is out of range" | |
129 | gas_m68hc11_error "-m68hc12" "orab -9,x-\n" \ | |
130 | "Increment/decrement value is out of range" | |
131 | gas_m68hc11_error "-m68hc12" "orab -3,-pc\n" \ | |
132 | "Invalid register for post/pre increment" | |
133 | gas_m68hc11_error "-m68hc12" "trap \#0\n" "Trap id .0. is out of range" | |
134 | gas_m68hc11_error "-m68hc12" "trap \#300\n" "Trap id .300. is out of range" | |
135 | gas_m68hc11_error "-m68hc12" "trap \#bar\n" "The trap id must be a constant" | |
136 | gas_m68hc11_error "-m68hc12" "sex x,d\n" \ | |
137 | "Invalid source register for this instruction, use .tfr." | |
138 | gas_m68hc11_error "-m68hc12" "tfr pc,a\n" "Invalid source register" | |
139 | gas_m68hc11_error "-m68hc12" "movb 200,x,3,y\n" \ | |
140 | "Offset out of 5-bit range for movw/movb insn: 200" | |
141 | gas_m68hc11_error "-m68hc12" "movb 2,x,300,y\n" \ | |
142 | "Offset out of 5-bit range for movw/movb insn: 300" | |
143 | ||
586b12ad SC |
144 | setup_xfail m6811-*-* |
145 | setup_xfail m6812-*-* | |
146 | gas_m68hc11_error "-m68hc12" "movb 2,x,bar,y\nbar=300\n" \ | |
147 | "Offset out of 5-bit range for movw/movb insn: 300" | |
148 | ||
f39f5da9 SC |
149 | # ------------------ |
150 | # Specific commands | |
151 | gas_m68hc11_warning "" ".mode \"bar\"\n" "Invalid mode: .bar." | |
152 | gas_m68hc11_error "" ".relax 23\n" "bad .relax format" | |
153 | gas_m68hc11_error "" ".relax bar-23\n" "bad .relax format" | |
154 | gas_m68hc11_warning "" ".far bar bar\n" "rest of line ignored" | |
155 | ||
156 | ||
60bcf0fa NC |
157 | run_dump_test insns |
158 | run_dump_test lbranch | |
159 | run_dump_test all_insns | |
68a581b8 SC |
160 | run_dump_test insns-dwarf2 |
161 | run_dump_test lbranch-dwarf2 | |
586b12ad SC |
162 | run_dump_test abi-m68hc11-16-64 |
163 | run_dump_test abi-m68hc11-16-32 | |
164 | run_dump_test abi-m68hc11-32-64 | |
60bcf0fa | 165 | |
4f69f974 SC |
166 | # Compliance with Motorola Assembly Language Input Standard |
167 | run_dump_test malis | |
168 | ||
60bcf0fa NC |
169 | # Some 68HC12 tests |
170 | run_dump_test opers12 | |
cd2b2939 SC |
171 | run_dump_test opers12-dwarf2 |
172 | run_dump_test branchs12 | |
173 | run_dump_test insns12 | |
27bdea3d SC |
174 | run_dump_test indexed12 |
175 | run_dump_test bug-1825 |