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 H8/300 elf tests 19# 20proc do_h8300_cbranch {} { 21 set testname "cbranch.s: h8300 conditional branch tests" 22 set x 0 23 24 gas_start "cbranch.s" "-al" 25 26 # Check each instruction bit pattern to verify it got 27 # assembled correctly. 28 while 1 { 29 expect { 30 -re " +\[0-9\]+ 0000 4000\[^\n\]*\n" { set x [expr $x+1] } 31 -re " +\[0-9\]+ 0002 4000\[^\n\]*\n" { set x [expr $x+1] } 32 -re " +\[0-9\]+ 0004 4100\[^\n\]*\n" { set x [expr $x+1] } 33 -re " +\[0-9\]+ 0006 4100\[^\n\]*\n" { set x [expr $x+1] } 34 -re " +\[0-9\]+ 0008 4200\[^\n\]*\n" { set x [expr $x+1] } 35 -re " +\[0-9\]+ 000a 4300\[^\n\]*\n" { set x [expr $x+1] } 36 -re " +\[0-9\]+ 000c 4400\[^\n\]*\n" { set x [expr $x+1] } 37 -re " +\[0-9\]+ 000e 4400\[^\n\]*\n" { set x [expr $x+1] } 38 -re " +\[0-9\]+ 0010 4500\[^\n\]*\n" { set x [expr $x+1] } 39 -re " +\[0-9\]+ 0012 4500\[^\n\]*\n" { set x [expr $x+1] } 40 -re " +\[0-9\]+ 0014 4600\[^\n\]*\n" { set x [expr $x+1] } 41 -re " +\[0-9\]+ 0016 4700\[^\n\]*\n" { set x [expr $x+1] } 42 -re " +\[0-9\]+ 0018 4800\[^\n\]*\n" { set x [expr $x+1] } 43 -re " +\[0-9\]+ 001a 4900\[^\n\]*\n" { set x [expr $x+1] } 44 -re " +\[0-9\]+ 001c 4A00\[^\n\]*\n" { set x [expr $x+1] } 45 -re " +\[0-9\]+ 001e 4B00\[^\n\]*\n" { set x [expr $x+1] } 46 -re " +\[0-9\]+ 0020 4C00\[^\n\]*\n" { set x [expr $x+1] } 47 -re " +\[0-9\]+ 0022 4D00\[^\n\]*\n" { set x [expr $x+1] } 48 -re " +\[0-9\]+ 0024 4E00\[^\n\]*\n" { set x [expr $x+1] } 49 -re " +\[0-9\]+ 0026 4F00\[^\n\]*\n" { set x [expr $x+1] } 50 timeout { perror "timeout\n; break } 51 eof { break } 52 } 53 } 54 55 # This was intended to do any cleanup necessary. It kinda looks like it 56 # isn't needed, but just in case, please keep it in for now. 57 gas_finish 58 59 # Did we find what we were looking for? If not, flunk it. 60 if [expr $x == 20] then { pass $testname } else { fail $testname } 61} 62 63proc do_h8300_branch {} { 64 set testname "branch.s: h8300 branch tests" 65 set x 0 66 67 gas_start "branch-elf.s" "-al" 68 69 # Check each instruction bit pattern to verify it got 70 # assembled correctly. 71 while 1 { 72 expect { 73 -re " +\[0-9\]+ 0000 5500\[^\n\]*\n" { set x [expr $x+1] } 74 -re " +\[0-9\]+ 0002 5A000000\[^\n\]*\n" { set x [expr $x+1] } 75 -re " +\[0-9\]+ 0006 5900\[^\n\]*\n" { set x [expr $x+1] } 76 -re " +\[0-9\]+ 0008 5B00\[^\n\]*\n" { set x [expr $x+1] } 77 -re " +\[0-9\]+ 000a 5E000000\[^\n\]*\n" { set x [expr $x+1] } 78 -re " +\[0-9\]+ 000e 5D00\[^\n\]*\n" { set x [expr $x+1] } 79 -re " +\[0-9\]+ 0010 5F00\[^\n\]*\n" { set x [expr $x+1] } 80 timeout { perror "timeout\n; break } 81 eof { break } 82 } 83 } 84 85 # This was intended to do any cleanup necessary. It kinda looks like it 86 # isn't needed, but just in case, please keep it in for now. 87 gas_finish 88 89 # Did we find what we were looking for? If not, flunk it. 90 if [expr $x == 7] then { pass $testname } else { fail $testname } 91} 92 93proc do_h8300h_cbranch {} { 94 set testname "cbranchh.s: h8300h conditional branch tests" 95 set x 0 96 97 gas_start "cbranchh.s" "-al" 98 99 # Check each instruction bit pattern to verify it got 100 # assembled correctly. 101 while 1 { 102 expect { 103 -re " +\[0-9\]+ 0000 4000\[^\n\]*\n" { set x [expr $x+1] } 104 -re " +\[0-9\]+ 0002 4000\[^\n\]*\n" { set x [expr $x+1] } 105 -re " +\[0-9\]+ 0004 4100\[^\n\]*\n" { set x [expr $x+1] } 106 -re " +\[0-9\]+ 0006 4100\[^\n\]*\n" { set x [expr $x+1] } 107 -re " +\[0-9\]+ 0008 4200\[^\n\]*\n" { set x [expr $x+1] } 108 -re " +\[0-9\]+ 000a 4300\[^\n\]*\n" { set x [expr $x+1] } 109 -re " +\[0-9\]+ 000c 4400\[^\n\]*\n" { set x [expr $x+1] } 110 -re " +\[0-9\]+ 000e 4400\[^\n\]*\n" { set x [expr $x+1] } 111 -re " +\[0-9\]+ 0010 4500\[^\n\]*\n" { set x [expr $x+1] } 112 -re " +\[0-9\]+ 0012 4500\[^\n\]*\n" { set x [expr $x+1] } 113 -re " +\[0-9\]+ 0014 4600\[^\n\]*\n" { set x [expr $x+1] } 114 -re " +\[0-9\]+ 0016 4700\[^\n\]*\n" { set x [expr $x+1] } 115 -re " +\[0-9\]+ 0018 4800\[^\n\]*\n" { set x [expr $x+1] } 116 -re " +\[0-9\]+ 001a 4900\[^\n\]*\n" { set x [expr $x+1] } 117 -re " +\[0-9\]+ 001c 4A00\[^\n\]*\n" { set x [expr $x+1] } 118 -re " +\[0-9\]+ 001e 4B00\[^\n\]*\n" { set x [expr $x+1] } 119 -re " +\[0-9\]+ 0020 4C00\[^\n\]*\n" { set x [expr $x+1] } 120 -re " +\[0-9\]+ 0022 4D00\[^\n\]*\n" { set x [expr $x+1] } 121 -re " +\[0-9\]+ 0024 4E00\[^\n\]*\n" { set x [expr $x+1] } 122 -re " +\[0-9\]+ 0026 4F00\[^\n\]*\n" { set x [expr $x+1] } 123 -re " +\[0-9\]+ 0028 58000000\[^\n\]*\n" { set x [expr $x+1] } 124 -re " +\[0-9\]+ 002c 58000000\[^\n\]*\n" { set x [expr $x+1] } 125 -re " +\[0-9\]+ 0030 58100000\[^\n\]*\n" { set x [expr $x+1] } 126 -re " +\[0-9\]+ 0034 58100000\[^\n\]*\n" { set x [expr $x+1] } 127 -re " +\[0-9\]+ 0038 58200000\[^\n\]*\n" { set x [expr $x+1] } 128 -re " +\[0-9\]+ 003c 58300000\[^\n\]*\n" { set x [expr $x+1] } 129 -re " +\[0-9\]+ 0040 58400000\[^\n\]*\n" { set x [expr $x+1] } 130 -re " +\[0-9\]+ 0044 58400000\[^\n\]*\n" { set x [expr $x+1] } 131 -re " +\[0-9\]+ 0048 58500000\[^\n\]*\n" { set x [expr $x+1] } 132 -re " +\[0-9\]+ 004c 58500000\[^\n\]*\n" { set x [expr $x+1] } 133 -re " +\[0-9\]+ 0050 58600000\[^\n\]*\n" { set x [expr $x+1] } 134 -re " +\[0-9\]+ 0054 58700000\[^\n\]*\n" { set x [expr $x+1] } 135 -re " +\[0-9\]+ 0058 58800000\[^\n\]*\n" { set x [expr $x+1] } 136 -re " +\[0-9\]+ 005c 58900000\[^\n\]*\n" { set x [expr $x+1] } 137 -re " +\[0-9\]+ 0060 58A00000\[^\n\]*\n" { set x [expr $x+1] } 138 -re " +\[0-9\]+ 0064 58B00000\[^\n\]*\n" { set x [expr $x+1] } 139 -re " +\[0-9\]+ 0068 58C00000\[^\n\]*\n" { set x [expr $x+1] } 140 -re " +\[0-9\]+ 006c 58D00000\[^\n\]*\n" { set x [expr $x+1] } 141 -re " +\[0-9\]+ 0070 58E00000\[^\n\]*\n" { set x [expr $x+1] } 142 -re " +\[0-9\]+ 0074 58F00000\[^\n\]*\n" { set x [expr $x+1] } 143 timeout { perror "timeout\n; break } 144 eof { break } 145 } 146 } 147 148 # This was intended to do any cleanup necessary. It kinda looks like it 149 # isn't needed, but just in case, please keep it in for now. 150 gas_finish 151 152 # Did we find what we were looking for? If not, flunk it. 153 if [expr $x == 40] then { pass $testname } else { fail $testname } 154} 155 156proc do_h8300h_branch {} { 157 set testname "branchh.s: h8300h branch tests" 158 set x 0 159 160 gas_start "branchh-elf.s" "-al" 161 162 # Check each instruction bit pattern to verify it got 163 # assembled correctly. 164 while 1 { 165 expect { 166 -re " +\[0-9\]+ 0000 5500\[^\n\]*\n" { set x [expr $x+1] } 167 -re " +\[0-9\]+ 0002 5C000000\[^\n\]*\n" { set x [expr $x+1] } 168 -re " +\[0-9\]+ 0006 5A000000\[^\n\]*\n" { set x [expr $x+1] } 169 -re " +\[0-9\]+ 000a 5900\[^\n\]*\n" { set x [expr $x+1] } 170 -re " +\[0-9\]+ 000c 5B00\[^\n\]*\n" { set x [expr $x+1] } 171 -re " +\[0-9\]+ 000e 5E000000\[^\n\]*\n" { set x [expr $x+1] } 172 -re " +\[0-9\]+ 0012 5D00\[^\n\]*\n" { set x [expr $x+1] } 173 -re " +\[0-9\]+ 0014 5F00\[^\n\]*\n" { set x [expr $x+1] } 174 timeout { perror "timeout\n; break } 175 eof { break } 176 } 177 } 178 179 # This was intended to do any cleanup necessary. It kinda looks like it 180 # isn't needed, but just in case, please keep it in for now. 181 gas_finish 182 183 # Did we find what we were looking for? If not, flunk it. 184 if [expr $x == 8] then { pass $testname } else { fail $testname } 185} 186 187proc do_h8300s_cbranch {} { 188 set testname "cbranchs.s: h8300s conditional branch tests" 189 set x 0 190 191 gas_start "cbranchs.s" "-al" 192 193 # Check each instruction bit pattern to verify it got 194 # assembled correctly. 195 while 1 { 196 expect { 197 -re " +\[0-9\]+ 0000 4000\[^\n\]*\n" { set x [expr $x+1] } 198 -re " +\[0-9\]+ 0002 4000\[^\n\]*\n" { set x [expr $x+1] } 199 -re " +\[0-9\]+ 0004 4100\[^\n\]*\n" { set x [expr $x+1] } 200 -re " +\[0-9\]+ 0006 4100\[^\n\]*\n" { set x [expr $x+1] } 201 -re " +\[0-9\]+ 0008 4200\[^\n\]*\n" { set x [expr $x+1] } 202 -re " +\[0-9\]+ 000a 4300\[^\n\]*\n" { set x [expr $x+1] } 203 -re " +\[0-9\]+ 000c 4400\[^\n\]*\n" { set x [expr $x+1] } 204 -re " +\[0-9\]+ 000e 4400\[^\n\]*\n" { set x [expr $x+1] } 205 -re " +\[0-9\]+ 0010 4500\[^\n\]*\n" { set x [expr $x+1] } 206 -re " +\[0-9\]+ 0012 4500\[^\n\]*\n" { set x [expr $x+1] } 207 -re " +\[0-9\]+ 0014 4600\[^\n\]*\n" { set x [expr $x+1] } 208 -re " +\[0-9\]+ 0016 4700\[^\n\]*\n" { set x [expr $x+1] } 209 -re " +\[0-9\]+ 0018 4800\[^\n\]*\n" { set x [expr $x+1] } 210 -re " +\[0-9\]+ 001a 4900\[^\n\]*\n" { set x [expr $x+1] } 211 -re " +\[0-9\]+ 001c 4A00\[^\n\]*\n" { set x [expr $x+1] } 212 -re " +\[0-9\]+ 001e 4B00\[^\n\]*\n" { set x [expr $x+1] } 213 -re " +\[0-9\]+ 0020 4C00\[^\n\]*\n" { set x [expr $x+1] } 214 -re " +\[0-9\]+ 0022 4D00\[^\n\]*\n" { set x [expr $x+1] } 215 -re " +\[0-9\]+ 0024 4E00\[^\n\]*\n" { set x [expr $x+1] } 216 -re " +\[0-9\]+ 0026 4F00\[^\n\]*\n" { set x [expr $x+1] } 217 -re " +\[0-9\]+ 0028 58000000\[^\n\]*\n" { set x [expr $x+1] } 218 -re " +\[0-9\]+ 002c 58000000\[^\n\]*\n" { set x [expr $x+1] } 219 -re " +\[0-9\]+ 0030 58100000\[^\n\]*\n" { set x [expr $x+1] } 220 -re " +\[0-9\]+ 0034 58100000\[^\n\]*\n" { set x [expr $x+1] } 221 -re " +\[0-9\]+ 0038 58200000\[^\n\]*\n" { set x [expr $x+1] } 222 -re " +\[0-9\]+ 003c 58300000\[^\n\]*\n" { set x [expr $x+1] } 223 -re " +\[0-9\]+ 0040 58400000\[^\n\]*\n" { set x [expr $x+1] } 224 -re " +\[0-9\]+ 0044 58400000\[^\n\]*\n" { set x [expr $x+1] } 225 -re " +\[0-9\]+ 0048 58500000\[^\n\]*\n" { set x [expr $x+1] } 226 -re " +\[0-9\]+ 004c 58500000\[^\n\]*\n" { set x [expr $x+1] } 227 -re " +\[0-9\]+ 0050 58600000\[^\n\]*\n" { set x [expr $x+1] } 228 -re " +\[0-9\]+ 0054 58700000\[^\n\]*\n" { set x [expr $x+1] } 229 -re " +\[0-9\]+ 0058 58800000\[^\n\]*\n" { set x [expr $x+1] } 230 -re " +\[0-9\]+ 005c 58900000\[^\n\]*\n" { set x [expr $x+1] } 231 -re " +\[0-9\]+ 0060 58A00000\[^\n\]*\n" { set x [expr $x+1] } 232 -re " +\[0-9\]+ 0064 58B00000\[^\n\]*\n" { set x [expr $x+1] } 233 -re " +\[0-9\]+ 0068 58C00000\[^\n\]*\n" { set x [expr $x+1] } 234 -re " +\[0-9\]+ 006c 58D00000\[^\n\]*\n" { set x [expr $x+1] } 235 -re " +\[0-9\]+ 0070 58E00000\[^\n\]*\n" { set x [expr $x+1] } 236 -re " +\[0-9\]+ 0074 58F00000\[^\n\]*\n" { set x [expr $x+1] } 237 timeout { perror "timeout\n; break } 238 eof { break } 239 } 240 } 241 242 # This was intended to do any cleanup necessary. It kinda looks like it 243 # isn't needed, but just in case, please keep it in for now. 244 gas_finish 245 246 # Did we find what we were looking for? If not, flunk it. 247 if [expr $x == 40] then { pass $testname } else { fail $testname } 248} 249 250proc do_h8300s_branch {} { 251 set testname "branchs.s: h8300s branch tests" 252 set x 0 253 254 gas_start "branchs-elf.s" "-al" 255 256 # Check each instruction bit pattern to verify it got 257 # assembled correctly. 258 while 1 { 259 expect { 260 -re " +\[0-9\]+ 0000 5500\[^\n\]*\n" { set x [expr $x+1] } 261 -re " +\[0-9\]+ 0002 5C000000\[^\n\]*\n" { set x [expr $x+1] } 262 -re " +\[0-9\]+ 0006 5A000000\[^\n\]*\n" { set x [expr $x+1] } 263 -re " +\[0-9\]+ 000a 5900\[^\n\]*\n" { set x [expr $x+1] } 264 -re " +\[0-9\]+ 000c 5B00\[^\n\]*\n" { set x [expr $x+1] } 265 -re " +\[0-9\]+ 000e 5E000000\[^\n\]*\n" { set x [expr $x+1] } 266 -re " +\[0-9\]+ 0012 5D00\[^\n\]*\n" { set x [expr $x+1] } 267 -re " +\[0-9\]+ 0014 5F00\[^\n\]*\n" { set x [expr $x+1] } 268 timeout { perror "timeout\n; break } 269 eof { break } 270 } 271 } 272 273 # This was intended to do any cleanup necessary. It kinda looks like it 274 # isn't needed, but just in case, please keep it in for now. 275 gas_finish 276 277 # Did we find what we were looking for? If not, flunk it. 278 if [expr $x == 8] then { pass $testname } else { fail $testname } 279} 280 281if [istarget h8300*-*-elf] then { 282 # Test the basic h8300 instruction parser 283 do_h8300_cbranch 284 do_h8300_branch 285 286 # Now test the h8300h instruction parser 287 do_h8300h_cbranch 288 do_h8300h_branch 289 290 # Now test the h8300s instruction parser 291 do_h8300s_cbranch 292 do_h8300s_branch 293 294 # Now some random tests 295 run_dump_test "ffxx1-elf" 296 297 run_dump_test h8sx_disp2 298 run_dump_test h8sx_rtsl 299 run_dump_test h8sx_mov_imm 300} 301