* gas/m68hc11/m68hc11.exp (gas_m68hc11_error): New function;
[external/binutils.git] / gas / testsuite / gas / m68hc11 / m68hc11.exp
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 }
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
35
36
37 # Test for a message produced when assembling a file
38 proc gas_m68hc11_message { kind options line expect } {
39     global srcdir
40     global subdir
41
42     regsub -all "\n" "$line: $expect" " " title
43
44     # Make a file containing the instructions to assemble.
45     set fd [open "$srcdir/$subdir/tst-m68hc1x.s" "w"];
46     puts -nonewline $fd "$line"
47     close $fd
48
49     verbose -log "Test: $title"
50     gas_start "tst-m68hc1x.s" "$options"
51     set ok 0
52     while 1 {
53         expect {
54             -re ".*: Assembler messages:\n" { }
55             -re ".*1: $kind: $expect" { incr ok; break }
56             timeout       { perror "timeout\n"; break }
57             eof           { verbose "EOF from gas"; break }
58         }
59     }
60     #sleep 1 # Uncomment this line when using gcov
61     gas_finish
62     if { $ok > 0 } then {
63         pass $title
64     } else {
65         fail $title
66     }
67     catch "exec rm -f $srcdir/$subdir/tst-m68hc1x.s"
68 }
69
70 # Test for an error message produced by gas
71 proc gas_m68hc11_error { options line expect } {
72     gas_m68hc11_message "Error" $options $line $expect
73 }
74
75 # Test for a warning message produced by gas
76 proc gas_m68hc11_warning { options line expect } {
77     gas_m68hc11_message "Warning" $options $line $expect
78 }
79
80 # ------------------
81 # 68HC11 error tests
82 gas_m68hc11_error "" "puld\n" "Opcode .puld. is not recognized"
83 gas_m68hc11_error "" "ldab\n" "Invalid operand for .ldab."
84 gas_m68hc11_error "" "ldab 256,x\n" "Operand out of 8-bit range:.*256"
85 gas_m68hc11_error "" "ldab 257,y\n" "Operand out of 8-bit range:.*257"
86 gas_m68hc11_error "" "ldab -1,y\n" "Operand out of 8-bit range:.*-1"
87 gas_m68hc11_error "" "ldab bar,y\nbar=300" "value of 300 too large for field of 1 byte"
88 gas_m68hc11_error "" "jmp \#23\n" "Immediate operand is not allowed"
89 gas_m68hc11_error "" "ldab \[d,pc\]\n" "Indirect indexed addressing is not valid for 68HC11"
90 gas_m68hc11_error "" "ldab ,t\n" "Spurious .,. or bad indirect register"
91 gas_m68hc11_error "" "ldab 1,t\n" "Garbage at end of instruction:.*,t"
92 gas_m68hc11_error "" "ldab 1,,x\n" "Garbage at end of instruction:.*,x"
93 gas_m68hc11_error "" "ldab 1,+x\n" "Pre-increment mode is not valid"
94 gas_m68hc11_error "" "ldab 1,-x\n" "Pre-increment mode is not valid"
95 gas_m68hc11_error "" "ldab 1,x+\n" "Post-increment mode is not valid"
96 gas_m68hc11_error "" "ldab 1,x-\n" "Post-decrement mode is not valid"
97 gas_m68hc11_error "" "ldd \#65536\n" "Operand out of 16-bit range"
98 gas_m68hc11_error "--short-branchs" "bne 200\n" \
99     "Operand out of range for a relative branch"
100 gas_m68hc11_error "" "bar\n" "Opcode .bar. is not recognized."
101 gas_m68hc11_error "--print-insn-syntax" "bne\n" \
102     "Instruction formats for .bne..*"
103
104 # ------------------
105 # 68HC12 error tests
106 gas_m68hc11_error "-m68hc12" "ldab x,y\n" "Invalid accumulator register"
107 gas_m68hc11_error "-m68hc12" "ldab \[d,y\n" \
108     "Missing .\]. to close indexed-indirect mode"
109 gas_m68hc11_error "-m68hc12" "ldab 0,\n" "Garbage at end of instruction: .,."
110 gas_m68hc11_error "-m68hc12" "ldab \[d\]\n" \
111     "Missing second register or offset for indexed-indirect mode"
112 gas_m68hc11_error "-m68hc12" "ldab \[d x\]\n" \
113     "Missing second register for indexed-indirect mode"
114 gas_m68hc11_error "-m68hc12" "ldab \[d d\]\n" \
115     "Missing second register for indexed-indirect mode"
116 gas_m68hc11_error "-m68hc12" "ldab \[pc d\]\n" \
117     "Missing second register for indexed-indirect mode"
118 gas_m68hc11_error "-m68hc12" "ldab 65536,x\n" \
119     "Offset out of 16-bit range:"
120 gas_m68hc11_error "-m68hc12 -S" "ibeq d,500\n" \
121     "Operand out of range for a relative branch"
122 gas_m68hc11_error "-m68hc12" "ibeq pc,3\n" \
123     "Invalid register for dbcc/tbcc instruction"
124 gas_m68hc11_error "-m68hc12 -S" "ibeq pc,500\n" \
125     "Invalid register for dbcc/tbcc instruction"
126 gas_m68hc11_error "-m68hc12" "orab 9,+x\n" \
127     "Increment/decrement value is out of range"
128 gas_m68hc11_error "-m68hc12" "orab -9,x-\n" \
129     "Increment/decrement value is out of range"
130 gas_m68hc11_error "-m68hc12" "orab -3,-pc\n" \
131     "Invalid register for post/pre increment"
132 gas_m68hc11_error "-m68hc12" "trap \#0\n" "Trap id .0. is out of range"
133 gas_m68hc11_error "-m68hc12" "trap \#300\n" "Trap id .300. is out of range"
134 gas_m68hc11_error "-m68hc12" "trap \#bar\n" "The trap id must be a constant"
135 gas_m68hc11_error "-m68hc12" "sex x,d\n" \
136     "Invalid source register for this instruction, use .tfr."
137 gas_m68hc11_error "-m68hc12" "tfr pc,a\n" "Invalid source register"
138 gas_m68hc11_error "-m68hc12" "movb 200,x,3,y\n" \
139     "Offset out of 5-bit range for movw/movb insn: 200"
140 gas_m68hc11_error "-m68hc12" "movb 2,x,300,y\n" \
141     "Offset out of 5-bit range for movw/movb insn: 300"
142
143 # ------------------
144 # Specific commands
145 gas_m68hc11_warning "" ".mode \"bar\"\n" "Invalid mode: .bar."
146 gas_m68hc11_error "" ".relax 23\n" "bad .relax format"
147 gas_m68hc11_error "" ".relax bar-23\n" "bad .relax format"
148 gas_m68hc11_warning "" ".far bar bar\n" "rest of line ignored"
149
150
151 run_dump_test insns
152 run_dump_test lbranch
153 run_dump_test all_insns
154 run_dump_test insns-dwarf2
155 run_dump_test lbranch-dwarf2
156
157 # Compliance with Motorola Assembly Language Input Standard
158 run_dump_test malis
159
160 # Some 68HC12 tests
161 run_dump_test opers12
162 run_dump_test opers12-dwarf2
163 run_dump_test branchs12
164 run_dump_test insns12
165 run_dump_test indexed12
166 run_dump_test bug-1825