1# Copyright (C) 2012-2014 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# 20if { ![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 29proc 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 45gas_m68hc11_opcode_list "-m68hc11" 149 46gas_m68hc11_opcode_list "-m68hc12" 192 47gas_m68hc11_opcode_list "-m68hcs12" 192 48gas_m68hc11_opcode_list "-mm9s12x" 266 49gas_m68hc11_opcode_list "-mm9s12xg" 74 50 51 52# Test for a message produced when assembling a file 53proc 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. 60 set fd [open "$srcdir/$subdir/tst-m68hc1x.s" "w"] 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 86proc 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 91proc gas_m68hc11_warning { options line expect } { 92 gas_m68hc11_message "Warning" $options $line $expect 93} 94 95# ------------------ 96# 68HC11 error tests 97gas_m68hc11_error "-m68hc11" "puld\n" "Opcode .puld. is not recognized" 98gas_m68hc11_error "" "ldab\n" "Invalid operand for .ldab." 99gas_m68hc11_error "-m68hc11" "ldab 256,x\n" "Operand out of 8-bit range:.*256" 100gas_m68hc11_error "-m68hc11" "ldab 257,y\n" "Operand out of 8-bit range:.*257" 101gas_m68hc11_error "-m68hc11" "ldab -1,y\n" "Operand out of 8-bit range:.*-1" 102gas_m68hc11_error "-m68hc11" "ldab bar,y\nbar=300" "value of 300 too large for field of 1 byte" 103gas_m68hc11_error "" "jmp \#23\n" "Immediate operand is not allowed" 104gas_m68hc11_error "-m68hc11" "ldab \[d,pc\]\n" "Indirect indexed addressing is not valid for 68HC11" 105gas_m68hc11_error "" "ldab ,t\n" "Spurious .,. or bad indirect register" 106gas_m68hc11_error "" "ldab 1,t\n" "Garbage at end of instruction:.*,t" 107gas_m68hc11_error "" "ldab 1,,x\n" "Garbage at end of instruction:.*,x" 108gas_m68hc11_error "-m68hc11" "ldab 1,+x\n" "Pre-increment mode is not valid" 109gas_m68hc11_error "-m68hc11" "ldab 1,-x\n" "Pre-increment mode is not valid" 110gas_m68hc11_error "-m68hc11" "ldab 1,x+\n" "Post-increment mode is not valid" 111gas_m68hc11_error "-m68hc11" "ldab 1,x-\n" "Post-decrement mode is not valid" 112gas_m68hc11_error "" "ldd \#65536\n" "Operand out of 16-bit range" 113gas_m68hc11_error "--short-branchs" "bne 200\n" \ 114 "Operand out of range for a relative branch" 115gas_m68hc11_error "" "bar\n" "Opcode .bar. is not recognized." 116gas_m68hc11_error "--print-insn-syntax" "bne\n" \ 117 "Instruction formats for .bne..*" 118#Check that 9s12x opcodes are rejected 119gas_m68hc11_error "-m68hc11" "subx\n" "Opcode .subx. is not recognized" 120gas_m68hc11_error "-m68hc11" "roly\n" "Opcode .roly. is not recognized" 121 122# ------------------ 123# 68HC12 error tests 124gas_m68hc11_error "-m68hc12" "ldab x,y\n" "Invalid accumulator register" 125gas_m68hc11_error "-m68hc12" "ldab \[d,y\n" \ 126 "Missing .\]. to close indexed-indirect mode" 127gas_m68hc11_error "-m68hc12" "ldab 0,\n" "Garbage at end of instruction: .,." 128gas_m68hc11_error "-m68hc12" "ldab \[d\]\n" \ 129 "Missing second register or offset for indexed-indirect mode" 130gas_m68hc11_error "-m68hc12" "ldab \[d x\]\n" \ 131 "Missing second register for indexed-indirect mode" 132gas_m68hc11_error "-m68hc12" "ldab \[d d\]\n" \ 133 "Missing second register for indexed-indirect mode" 134gas_m68hc11_error "-m68hc12" "ldab \[pc d\]\n" \ 135 "Missing second register for indexed-indirect mode" 136gas_m68hc11_error "-m68hc12" "ldab 65536,x\n" \ 137 "Offset out of 16-bit range:" 138gas_m68hc11_error "-m68hc12 -S" "ibeq d,500\n" \ 139 "Operand out of range for a relative branch" 140gas_m68hc11_error "-m68hc12" "ibeq pc,3\n" \ 141 "Invalid register for dbcc/tbcc instruction" 142gas_m68hc11_error "-m68hc12 -S" "ibeq pc,500\n" \ 143 "Invalid register for dbcc/tbcc instruction" 144gas_m68hc11_error "-m68hc12" "orab 9,+x\n" \ 145 "Increment/decrement value is out of range" 146gas_m68hc11_error "-m68hc12" "orab -9,x-\n" \ 147 "Increment/decrement value is out of range" 148gas_m68hc11_error "-m68hc12" "orab -3,-pc\n" \ 149 "Invalid register for post/pre increment" 150gas_m68hc11_error "-m68hc12" "trap \#0\n" "Trap id .0. is out of range" 151gas_m68hc11_error "-m68hc12" "trap \#300\n" "Trap id .300. is out of range" 152gas_m68hc11_error "-m68hc12" "trap \#bar\n" "The trap id must be a constant" 153gas_m68hc11_error "-m68hc12" "sex x,d\n" \ 154 "Invalid source register for this instruction, use .tfr." 155gas_m68hc11_error "-m68hc12" "tfr pc,a\n" "Invalid source register" 156gas_m68hc11_error "-m68hc12" "movb 200,x,3,y\n" \ 157 "Offset out of 5-bit range for movw/movb insn: 200" 158gas_m68hc11_error "-m68hc12" "movb 2,x,300,y\n" \ 159 "Offset out of 5-bit range for movw/movb insn: 300" 160gas_m68hc11_error "-m68hc12" "movb 2,x,bar,y\nbar=300\n" \ 161 "Offset out of 5-bit range for movw/movb insn: 300" 162gas_m68hc11_error "-m68hc12" "movb bar,y,2,x\nbar=300\n" \ 163 "Offset out of 5-bit range for movw/movb insn: 300" 164gas_m68hc11_error "-m68hc12" "movb 200,pc,3,y\n" \ 165 "Offset out of 5-bit range for movw/movb insn: 200" 166gas_m68hc11_error "-m68hc12" "movb 2,x,300,pc\n" \ 167 "Offset out of 5-bit range for movw/movb insn: 300" 168gas_m68hc11_error "-m68hc12" "movb 2,x,bar,pc\nbar=300\n" \ 169 "Offset out of 5-bit range for movw/movb insn: 300" 170gas_m68hc11_error "-m68hc12" "movb bar,pc,2,x\nbar=300\n" \ 171 "Offset out of 5-bit range for movw/movb insn: 300" 172#check the 9s12x opcodes not supported 173gas_m68hc11_error "-m68hc12" "subx\n" "Opcode .subx. is not recognized" 174gas_m68hc11_error "-m68hc12" "roly\n" "Opcode .roly. is not recognized" 175gas_m68hc11_error "-m68hc12" "sex d,x\n" \ 176 "Invalid source register for this instruction, use .tfr." 177gas_m68hc11_error "-m68hc12" "sex d,y\n" \ 178 "Invalid source register for this instruction, use .tfr." 179 180#m9s12x tests 181gas_m68hc11_error "-mm9s12x" "par r3\n" "Opcode .par. is not recognized" 182gas_m68hc11_error "-mm9s12x" "csem #1\n" "Opcode .csem. is not recognized" 183 184#m9s12xg tests 185gas_m68hc11_error "-mm9s12xg" "roly\n" "Opcode .roly. is not recognized" 186gas_m68hc11_error "-mm9s12xg" "ldab #1\n" "Opcode .ldab. is not recognized" 187 188# ------------------ 189# Specific commands 190gas_m68hc11_warning "-m68hc11" ".mode \"bar\"\n" "Invalid mode: .bar." 191gas_m68hc11_error "-m68hc11" ".relax 23\n" "bad .relax format" 192gas_m68hc11_error "-m68hc11" ".relax bar-23\n" "bad .relax format" 193gas_m68hc11_error "-m68hc11" ".far bar bar\n" "junk at end of line" 194 195run_dump_test insns 196run_dump_test lbranch 197run_dump_test all_insns 198run_dump_test insns-dwarf2 199run_dump_test lbranch-dwarf2 200run_dump_test abi-m68hc11-16-64 201run_dump_test abi-m68hc11-16-32 202run_dump_test abi-m68hc11-32-64 203 204# Compliance with Motorola Assembly Language Input Standard 205run_dump_test malis 206 207# Some 68HC12 tests 208run_dump_test opers12 209run_dump_test opers12-dwarf2 210run_dump_test branchs12 211run_dump_test insns12 212run_dump_test indexed12 213run_dump_test bug-1825 214run_dump_test movb 215 216# Some m9s12x tests 217run_dump_test insns9s12x 218run_dump_test 9s12x-exg-sex-tfr 219run_dump_test 9s12x-mov 220 221# Some m9s12xg tests 222run_dump_test insns9s12xg 223 224# Confirm hex prefixes 225run_dump_test hexprefix 226 227