File: m68hc11.exp

package info (click to toggle)
binutils 2.32.51.20190821-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 309,676 kB
  • sloc: ansic: 1,201,497; asm: 658,869; cpp: 130,432; exp: 69,370; makefile: 56,804; sh: 23,583; lisp: 14,519; yacc: 14,467; perl: 2,111; ada: 1,681; lex: 1,649; pascal: 1,446; python: 991; cs: 879; sed: 195; xml: 95; awk: 25
file content (226 lines) | stat: -rw-r--r-- 8,876 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Copyright (C) 2012-2019 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  

#
# Some generic m68HC11 tests
#
if { ![istarget "m68hc1*-*-*"]
     && ![istarget "m6811-*-*"]
     && ![istarget "m6812-*-*"] } then {
    return
}

# Simple test for --print-opcodes (list of supported opcodes)
# We don't check the list result but just the syntax and the
# number it 
proc gas_m68hc11_opcode_list { flags expect_count } {
    global comp_output

    set testname "Opcode list generation \[$flags\]"
    gas_run "x.s" "--print-opcodes $flags" ""

    set lines [split $comp_output "\n"]
    set cnt [llength $lines]
    verbose -log "Found $cnt opcodes"
    if { $cnt == $expect_count } then {
        pass $testname
    } else {
        fail $testname
    }
}

gas_m68hc11_opcode_list "-m68hc11" 149
gas_m68hc11_opcode_list "-m68hc12" 192
gas_m68hc11_opcode_list "-m68hcs12" 192
gas_m68hc11_opcode_list "-mm9s12x" 266
gas_m68hc11_opcode_list "-mm9s12xg" 74


# Test for a message produced when assembling a file
proc gas_m68hc11_message { kind options line expect } {
    global srcdir
    global subdir

    regsub -all "\n" "$line: $expect" " " title

    # Make a file containing the instructions to assemble.
    set fd [open "$srcdir/$subdir/tst-m68hc1x.s" "w"]
    puts -nonewline $fd "$line"
    close $fd

    verbose -log "Test: $title"
    gas_start "tst-m68hc1x.s" "$options"
    set ok 0
    while 1 {
	expect {
	    -re ".*: Assembler messages:\n" { }
	    -re ".*1: $kind: $expect" { incr ok; break }
	    timeout       { perror "timeout\n"; break }
	    eof		  { verbose "EOF from gas"; break }
	}
    }
    #sleep 1 # Uncomment this line when using gcov
    gas_finish
    if { $ok > 0 } then {
	pass $title
    } else {
	fail $title
    }
    catch "exec rm -f $srcdir/$subdir/tst-m68hc1x.s"
}

# Test for an error message produced by gas
proc gas_m68hc11_error { options line expect } {
    gas_m68hc11_message "Error" $options $line $expect
}

# Test for a warning message produced by gas
proc gas_m68hc11_warning { options line expect } {
    gas_m68hc11_message "Warning" $options $line $expect
}

# ------------------
# 68HC11 error tests
gas_m68hc11_error "-m68hc11" "puld\n" "Opcode .puld. is not recognized"
gas_m68hc11_error "" "ldab\n" "Invalid operand for .ldab."
gas_m68hc11_error "-m68hc11" "ldab 256,x\n" "Operand out of 8-bit range:.*256"
gas_m68hc11_error "-m68hc11" "ldab 257,y\n" "Operand out of 8-bit range:.*257"
gas_m68hc11_error "-m68hc11" "ldab -1,y\n" "Operand out of 8-bit range:.*-1"
gas_m68hc11_error "-m68hc11" "ldab bar,y\nbar=300" "value of 300 too large for field of 1 byte"
gas_m68hc11_error "" "jmp \#23\n" "Immediate operand is not allowed"
gas_m68hc11_error "-m68hc11" "ldab \[d,pc\]\n" "Indirect indexed addressing is not valid for 68HC11"
gas_m68hc11_error "" "ldab ,t\n" "Spurious .,. or bad indirect register"
gas_m68hc11_error "" "ldab 1,t\n" "Garbage at end of instruction:.*,t"
gas_m68hc11_error "" "ldab 1,,x\n" "Garbage at end of instruction:.*,x"
gas_m68hc11_error "-m68hc11" "ldab 1,+x\n" "Pre-increment mode is not valid"
gas_m68hc11_error "-m68hc11" "ldab 1,-x\n" "Pre-increment mode is not valid"
gas_m68hc11_error "-m68hc11" "ldab 1,x+\n" "Post-increment mode is not valid"
gas_m68hc11_error "-m68hc11" "ldab 1,x-\n" "Post-decrement mode is not valid"
gas_m68hc11_error "" "ldd \#65536\n" "Operand out of 16-bit range"
gas_m68hc11_error "--short-branchs" "bne 200\n" \
    "Operand out of range for a relative branch"
gas_m68hc11_error "" "bar\n" "Opcode .bar. is not recognized."
gas_m68hc11_error "--print-insn-syntax" "bne\n" \
    "Instruction formats for .bne..*"
#Check that 9s12x opcodes are rejected
gas_m68hc11_error "-m68hc11" "subx\n" "Opcode .subx. is not recognized"
gas_m68hc11_error "-m68hc11" "roly\n" "Opcode .roly. is not recognized"

# ------------------
# 68HC12 error tests
gas_m68hc11_error "-m68hc12" "ldab x,y\n" "Invalid accumulator register"
gas_m68hc11_error "-m68hc12" "ldab \[d,y\n" \
    "Missing .\]. to close indexed-indirect mode"
gas_m68hc11_error "-m68hc12" "ldab 0,\n" "Garbage at end of instruction: .,."
gas_m68hc11_error "-m68hc12" "ldab \[d\]\n" \
    "Missing second register or offset for indexed-indirect mode"
gas_m68hc11_error "-m68hc12" "ldab \[d x\]\n" \
    "Missing second register for indexed-indirect mode"
gas_m68hc11_error "-m68hc12" "ldab \[d d\]\n" \
    "Missing second register for indexed-indirect mode"
gas_m68hc11_error "-m68hc12" "ldab \[pc d\]\n" \
    "Missing second register for indexed-indirect mode"
gas_m68hc11_error "-m68hc12" "ldab 65536,x\n" \
    "Offset out of 16-bit range:"
gas_m68hc11_error "-m68hc12 -S" "ibeq d,500\n" \
    "Operand out of range for a relative branch"
gas_m68hc11_error "-m68hc12" "ibeq pc,3\n" \
    "Invalid register for dbcc/tbcc instruction"
gas_m68hc11_error "-m68hc12 -S" "ibeq pc,500\n" \
    "Invalid register for dbcc/tbcc instruction"
gas_m68hc11_error "-m68hc12" "orab 9,+x\n" \
    "Increment/decrement value is out of range"
gas_m68hc11_error "-m68hc12" "orab -9,x-\n" \
    "Increment/decrement value is out of range"
gas_m68hc11_error "-m68hc12" "orab -3,-pc\n" \
    "Invalid register for post/pre increment"
gas_m68hc11_error "-m68hc12" "trap \#0\n" "Trap id .0. is out of range"
gas_m68hc11_error "-m68hc12" "trap \#300\n" "Trap id .300. is out of range"
gas_m68hc11_error "-m68hc12" "trap \#bar\n" "The trap id must be a constant"
gas_m68hc11_error "-m68hc12" "sex x,d\n" \
    "Invalid source register for this instruction, use .tfr."
gas_m68hc11_error "-m68hc12" "tfr pc,a\n" "Invalid source register"
gas_m68hc11_error "-m68hc12" "movb 200,x,3,y\n" \
    "Offset out of 5-bit range for movw/movb insn: 200"
gas_m68hc11_error "-m68hc12" "movb 2,x,300,y\n" \
    "Offset out of 5-bit range for movw/movb insn: 300"
gas_m68hc11_error "-m68hc12" "movb 2,x,bar,y\nbar=300\n" \
    "Offset out of 5-bit range for movw/movb insn: 300"
gas_m68hc11_error "-m68hc12" "movb bar,y,2,x\nbar=300\n" \
    "Offset out of 5-bit range for movw/movb insn: 300"
gas_m68hc11_error "-m68hc12" "movb 200,pc,3,y\n" \
    "Offset out of 5-bit range for movw/movb insn: 200"
gas_m68hc11_error "-m68hc12" "movb 2,x,300,pc\n" \
    "Offset out of 5-bit range for movw/movb insn: 300"
gas_m68hc11_error "-m68hc12" "movb 2,x,bar,pc\nbar=300\n" \
    "Offset out of 5-bit range for movw/movb insn: 300"
gas_m68hc11_error "-m68hc12" "movb bar,pc,2,x\nbar=300\n" \
    "Offset out of 5-bit range for movw/movb insn: 300"
#check the 9s12x opcodes not supported
gas_m68hc11_error "-m68hc12" "subx\n" "Opcode .subx. is not recognized"
gas_m68hc11_error "-m68hc12" "roly\n" "Opcode .roly. is not recognized"
gas_m68hc11_error "-m68hc12" "sex d,x\n" \
    "Invalid source register for this instruction, use .tfr."
gas_m68hc11_error "-m68hc12" "sex d,y\n" \
    "Invalid source register for this instruction, use .tfr."

#m9s12x tests
gas_m68hc11_error "-mm9s12x" "par r3\n" "Opcode .par. is not recognized"
gas_m68hc11_error "-mm9s12x" "csem #1\n" "Opcode .csem. is not recognized"

#m9s12xg tests
gas_m68hc11_error "-mm9s12xg" "roly\n" "Opcode .roly. is not recognized"
gas_m68hc11_error "-mm9s12xg" "ldab #1\n" "Opcode .ldab. is not recognized"

# ------------------
# Specific commands
gas_m68hc11_warning "-m68hc11" ".mode \"bar\"\n" "Invalid mode: .bar."
gas_m68hc11_error "-m68hc11" ".relax 23\n" "bad .relax format"
gas_m68hc11_error "-m68hc11" ".relax bar-23\n" "bad .relax format"
gas_m68hc11_error "-m68hc11" ".far bar bar\n" "junk at end of line"

run_dump_test insns
run_dump_test lbranch
run_dump_test all_insns
run_dump_test insns-dwarf2
run_dump_test lbranch-dwarf2
run_dump_test abi-m68hc11-16-64
run_dump_test abi-m68hc11-16-32
run_dump_test abi-m68hc11-32-64

# Compliance with Motorola Assembly Language Input Standard
run_dump_test malis

# Some 68HC12 tests
run_dump_test opers12
run_dump_test opers12-dwarf2
run_dump_test branchs12
run_dump_test insns12
run_dump_test indexed12
run_dump_test bug-1825
run_dump_test movb

# Some m9s12x tests
run_dump_test insns9s12x
run_dump_test 9s12x-exg-sex-tfr
run_dump_test 9s12x-mov

# Some m9s12xg tests
run_dump_test insns9s12xg

# Confirm hex prefixes
run_dump_test hexprefix