band.s 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. # Hitachi H8 testcase 'band', 'bor', 'bxor', 'bld', 'bst', 'bstz'
  2. # mach(): all
  3. # as(h8300): --defsym sim_cpu=0
  4. # as(h8300h): --defsym sim_cpu=1
  5. # as(h8300s): --defsym sim_cpu=2
  6. # as(h8sx): --defsym sim_cpu=3
  7. # ld(h8300h): -m h8300helf
  8. # ld(h8300s): -m h8300self
  9. # ld(h8sx): -m h8300sxelf
  10. .include "testutils.inc"
  11. .data
  12. byte_src: .byte 0xa5
  13. byte_dst: .byte 0
  14. start
  15. band_imm3_reg8:
  16. set_grs_a5a5
  17. set_ccr_zero
  18. ;; band xx:3, reg8
  19. band #7, r0l ; this should NOT set the carry flag.
  20. test_cc_clear
  21. band #6, r0l ; this should NOT set the carry flag.
  22. test_cc_clear
  23. orc #1, ccr ; set the carry flag
  24. band #7, r0l ; this should NOT clear the carry flag
  25. test_carry_set
  26. test_ovf_clear
  27. test_neg_clear
  28. test_zero_clear
  29. band #6, r0l ; this should clear the carry flag
  30. test_cc_clear
  31. test_grs_a5a5 ; general registers should not be changed.
  32. band_imm3_ind:
  33. set_grs_a5a5
  34. .if (sim_cpu == h8300)
  35. mov #byte_src, r1
  36. set_ccr_zero
  37. ;; band xx:3, ind
  38. band #7, @r1 ; this should NOT set the carry flag.
  39. test_cc_clear
  40. band #6, @r1 ; this should NOT set the carry flag.
  41. test_cc_clear
  42. orc #1, ccr ; set the carry flag
  43. band #7, @r1 ; this should NOT clear the carry flag
  44. test_carry_set
  45. test_ovf_clear
  46. test_neg_clear
  47. test_zero_clear
  48. band #6, @r1 ; this should clear the carry flag
  49. test_cc_clear
  50. ;;; test_h_gr16 byte_src r1 ;FIXME
  51. .else
  52. mov #byte_src, er1
  53. set_ccr_zero
  54. ;; band xx:3, ind
  55. band #7, @er1 ; this should NOT set the carry flag.
  56. test_cc_clear
  57. band #6, @er1 ; this should NOT set the carry flag.
  58. test_cc_clear
  59. orc #1, ccr ; set the carry flag
  60. band #7, @er1 ; this should NOT clear the carry flag
  61. test_carry_set
  62. test_ovf_clear
  63. test_neg_clear
  64. test_zero_clear
  65. band #6, @er1 ; this should clear the carry flag
  66. test_cc_clear
  67. test_h_gr32 byte_src er1
  68. .endif ; h8300
  69. test_gr_a5a5 0 ; general registers should not be changed.
  70. test_gr_a5a5 2
  71. test_gr_a5a5 3
  72. test_gr_a5a5 4
  73. test_gr_a5a5 5
  74. test_gr_a5a5 6
  75. test_gr_a5a5 7
  76. band_imm3_abs8:
  77. set_grs_a5a5
  78. mov.b r1l, @0x20
  79. set_ccr_zero
  80. ;; band xx:3, aa:8
  81. band #7, @0x20:8 ; this should NOT set the carry flag.
  82. test_cc_clear
  83. band #6, @0x20:8 ; this should NOT set the carry flag.
  84. test_cc_clear
  85. orc #1, ccr ; set the carry flag
  86. band #7, @0x20:8 ; this should NOT clear the carry flag
  87. test_carry_set
  88. test_ovf_clear
  89. test_neg_clear
  90. test_zero_clear
  91. band #6, @0x20:8 ; this should clear the carry flag
  92. test_cc_clear
  93. test_grs_a5a5 ; general registers should not be changed.
  94. .if (sim_cpu > h8300h)
  95. band_imm3_abs16:
  96. set_grs_a5a5
  97. set_ccr_zero
  98. ;; band xx:3, aa:16
  99. band #7, @byte_src:16 ; this should NOT set the carry flag.
  100. test_cc_clear
  101. band #6, @byte_src:16 ; this should NOT set the carry flag.
  102. test_cc_clear
  103. orc #1, ccr ; set the carry flag
  104. band #7, @byte_src:16 ; this should NOT clear the carry flag
  105. test_carry_set
  106. test_ovf_clear
  107. test_neg_clear
  108. test_zero_clear
  109. band #6, @byte_src:16 ; this should clear the carry flag
  110. test_cc_clear
  111. test_grs_a5a5 ; general registers should not be changed.
  112. band_imm3_abs32:
  113. set_grs_a5a5
  114. set_ccr_zero
  115. ;; band xx:3, aa:32
  116. band #7, @byte_src:32 ; this should NOT set the carry flag.
  117. test_cc_clear
  118. band #6, @byte_src:32 ; this should NOT set the carry flag.
  119. test_cc_clear
  120. orc #1, ccr ; set the carry flag
  121. band #7, @byte_src:32 ; this should NOT clear the carry flag
  122. test_carry_set
  123. test_ovf_clear
  124. test_neg_clear
  125. test_zero_clear
  126. band #6, @byte_src:32 ; this should clear the carry flag
  127. test_cc_clear
  128. test_grs_a5a5 ; general registers should not be changed.
  129. .endif
  130. bor_imm3_reg8:
  131. set_grs_a5a5
  132. set_ccr_zero
  133. ;; bor xx:3, reg8
  134. bor #6, r0l ; this should NOT set the carry flag.
  135. test_cc_clear
  136. bor #7, r0l ; this should set the carry flag.
  137. test_carry_set
  138. test_ovf_clear
  139. test_neg_clear
  140. test_zero_clear
  141. orc #1, ccr ; set the carry flag
  142. bor #7, r0l ; this should NOT clear the carry flag
  143. test_carry_set
  144. test_ovf_clear
  145. test_neg_clear
  146. test_zero_clear
  147. bor #6, r0l ; this should NOT clear the carry flag
  148. test_carry_set
  149. test_ovf_clear
  150. test_neg_clear
  151. test_zero_clear
  152. test_grs_a5a5 ; general registers should not be changed.
  153. bor_imm3_abs8:
  154. set_grs_a5a5
  155. mov.b r1l, @0x20
  156. set_ccr_zero
  157. ;; bor xx:3, aa:8
  158. bor #6, @0x20:8 ; this should NOT set the carry flag.
  159. test_cc_clear
  160. bor #7, @0x20:8 ; this should set the carry flag.
  161. test_carry_set
  162. test_ovf_clear
  163. test_neg_clear
  164. test_zero_clear
  165. orc #1, ccr ; set the carry flag
  166. bor #7, @0x20:8 ; this should NOT clear the carry flag
  167. test_carry_set
  168. test_ovf_clear
  169. test_neg_clear
  170. test_zero_clear
  171. bor #6, @0x20:8 ; this should NOT clear the carry flag
  172. test_carry_set
  173. test_ovf_clear
  174. test_neg_clear
  175. test_zero_clear
  176. test_grs_a5a5 ; general registers should not be changed.
  177. bxor_imm3_reg8:
  178. set_grs_a5a5
  179. set_ccr_zero
  180. ;; bxor xx:3, reg8
  181. bxor #6, r0l ; this should NOT set the carry flag.
  182. test_cc_clear
  183. bxor #7, r0l ; this should set the carry flag.
  184. test_carry_set
  185. test_ovf_clear
  186. test_neg_clear
  187. test_zero_clear
  188. orc #1, ccr ; set the carry flag
  189. bxor #6, r0l ; this should NOT clear the carry flag
  190. test_carry_set
  191. test_ovf_clear
  192. test_neg_clear
  193. test_zero_clear
  194. bxor #7, r0l ; this should clear the carry flag
  195. test_cc_clear
  196. test_grs_a5a5 ; general registers should not be changed.
  197. bxor_imm3_abs8:
  198. set_grs_a5a5
  199. mov.b r1l, @0x20
  200. set_ccr_zero
  201. ;; bxor xx:3, aa:8
  202. bxor #6, @0x20:8 ; this should NOT set the carry flag.
  203. test_cc_clear
  204. bxor #7, @0x20:8 ; this should set the carry flag.
  205. test_carry_set
  206. test_ovf_clear
  207. test_neg_clear
  208. test_zero_clear
  209. orc #1, ccr ; set the carry flag
  210. bxor #6, @0x20:8 ; this should NOT clear the carry flag
  211. test_carry_set
  212. test_ovf_clear
  213. test_neg_clear
  214. test_zero_clear
  215. bxor #7, @0x20:8 ; this should clear the carry flag
  216. test_cc_clear
  217. test_grs_a5a5 ; general registers should not be changed.
  218. bld_imm3_reg8:
  219. set_grs_a5a5
  220. set_ccr_zero
  221. ;; bld xx:3, reg8
  222. bld #6, r0l ; this should NOT set the carry flag.
  223. test_cc_clear
  224. bld #7, r0l ; this should set the carry flag.
  225. test_carry_set
  226. test_ovf_clear
  227. test_neg_clear
  228. test_zero_clear
  229. test_grs_a5a5 ; general registers should not be changed.
  230. bld_imm3_ind:
  231. set_grs_a5a5
  232. .if (sim_cpu == h8300)
  233. mov #byte_src, r1
  234. set_ccr_zero
  235. ;; bld xx:3, ind
  236. bld #6, @r1 ; this should NOT set the carry flag.
  237. test_cc_clear
  238. bld #7, @r1 ; this should set the carry flag.
  239. test_carry_set
  240. test_ovf_clear
  241. test_neg_clear
  242. test_zero_clear
  243. ;;; test_h_gr16 byte_src r1 ;FIXME
  244. .else
  245. mov #byte_src, er1
  246. set_ccr_zero
  247. ;; bld xx:3, ind
  248. bld #6, @er1 ; this should NOT set the carry flag.
  249. test_cc_clear
  250. bld #7, @er1 ; this should NOT set the carry flag.
  251. test_carry_set
  252. test_ovf_clear
  253. test_neg_clear
  254. test_zero_clear
  255. test_h_gr32 byte_src er1
  256. .endif ; h8300
  257. test_gr_a5a5 0 ; general registers should not be changed.
  258. test_gr_a5a5 2
  259. test_gr_a5a5 3
  260. test_gr_a5a5 4
  261. test_gr_a5a5 5
  262. test_gr_a5a5 6
  263. test_gr_a5a5 7
  264. bld_imm3_abs8:
  265. set_grs_a5a5
  266. mov.b r1l, @0x20
  267. set_ccr_zero
  268. ;; bld xx:3, aa:8
  269. bld #6, @0x20:8 ; this should NOT set the carry flag.
  270. test_cc_clear
  271. bld #7, @0x20:8 ; this should set the carry flag.
  272. test_carry_set
  273. test_ovf_clear
  274. test_neg_clear
  275. test_zero_clear
  276. test_grs_a5a5 ; general registers should not be changed.
  277. .if (sim_cpu > h8300h)
  278. bld_imm3_abs16:
  279. set_grs_a5a5
  280. set_ccr_zero
  281. ;; bld xx:3, aa:16
  282. bld #6, @byte_src:16 ; this should NOT set the carry flag.
  283. test_cc_clear
  284. bld #7, @byte_src:16 ; this should set the carry flag.
  285. test_carry_set
  286. test_ovf_clear
  287. test_neg_clear
  288. test_zero_clear
  289. test_grs_a5a5 ; general registers should not be changed.
  290. bld_imm3_abs32:
  291. set_grs_a5a5
  292. set_ccr_zero
  293. ;; bld xx:3, aa:32
  294. bld #6, @byte_src:32 ; this should NOT set the carry flag.
  295. test_cc_clear
  296. bld #7, @byte_src:32 ; this should set the carry flag.
  297. test_carry_set
  298. test_ovf_clear
  299. test_neg_clear
  300. test_zero_clear
  301. test_grs_a5a5 ; general registers should not be changed.
  302. .endif
  303. bst_imm3_reg8:
  304. set_grs_a5a5
  305. set_ccr_zero
  306. ;; bst xx:3, reg8
  307. bst #7, r0l ; this should clear bit 7
  308. test_cc_clear
  309. test_h_gr16 0xa525 r0
  310. set_ccr_zero
  311. orc #1, ccr ; set the carry flag
  312. bst #6, r0l ; this should set bit 6
  313. test_carry_set
  314. test_ovf_clear
  315. test_neg_clear
  316. test_zero_clear
  317. test_h_gr16 0xa565 r0
  318. test_gr_a5a5 1 ; Rest of general regs should not be changed.
  319. test_gr_a5a5 2
  320. test_gr_a5a5 3
  321. test_gr_a5a5 4
  322. test_gr_a5a5 5
  323. test_gr_a5a5 6
  324. test_gr_a5a5 7
  325. bst_imm3_abs8:
  326. set_grs_a5a5
  327. mov.b r1l, @0x20
  328. set_ccr_zero
  329. ;; bst xx:3, aa:8
  330. bst #7, @0x20:8 ; this should clear bit 7
  331. test_cc_clear
  332. mov.b @0x20, r0l
  333. test_h_gr16 0xa525 r0
  334. set_ccr_zero
  335. orc #1, ccr ; set the carry flag
  336. bst #6, @0x20:8 ; this should set bit 6
  337. test_carry_set
  338. test_ovf_clear
  339. test_neg_clear
  340. test_zero_clear
  341. mov.b @0x20, r0l
  342. test_h_gr16 0xa565 r0
  343. test_gr_a5a5 1 ; general registers should not be changed.
  344. test_gr_a5a5 2
  345. test_gr_a5a5 3
  346. test_gr_a5a5 4
  347. test_gr_a5a5 5
  348. test_gr_a5a5 6
  349. test_gr_a5a5 7
  350. .if (sim_cpu == h8sx)
  351. bstz_imm3_abs8:
  352. set_grs_a5a5
  353. mov.b r1l, @0x20
  354. set_ccr_zero
  355. ;; bstz xx:3, aa:8
  356. bstz #7, @0x20:8 ; this should clear bit 7
  357. test_cc_clear
  358. mov.b @0x20, r0l
  359. test_h_gr16 0xa525 r0
  360. set_ccr_zero
  361. orc #4, ccr ; set the zero flag
  362. bstz #6, @0x20:8 ; this should set bit 6
  363. test_carry_clear
  364. test_ovf_clear
  365. test_neg_clear
  366. test_zero_set
  367. mov.b @0x20, r0l
  368. test_h_gr16 0xa565 r0
  369. test_gr_a5a5 1 ; general registers should not be changed.
  370. test_gr_a5a5 2
  371. test_gr_a5a5 3
  372. test_gr_a5a5 4
  373. test_gr_a5a5 5
  374. test_gr_a5a5 6
  375. test_gr_a5a5 7
  376. .endif ; h8sx
  377. btst_imm3_reg8:
  378. set_grs_a5a5
  379. set_ccr_zero
  380. ;; btst xx:3, reg8
  381. btst #7, r0l ; this should NOT set the zero flag.
  382. test_cc_clear
  383. btst #6, r0l ; this should set the zero flag.
  384. test_carry_clear
  385. test_ovf_clear
  386. test_neg_clear
  387. test_zero_set
  388. test_grs_a5a5 ; general registers should not be changed.
  389. btst_imm3_ind:
  390. set_grs_a5a5
  391. .if (sim_cpu == h8300)
  392. mov #byte_src, r1
  393. set_ccr_zero
  394. ;; btst xx:3, ind
  395. btst #7, @r1 ; this should NOT set the zero flag.
  396. test_cc_clear
  397. btst #6, @r1 ; this should set the zero flag.
  398. test_carry_clear
  399. test_ovf_clear
  400. test_neg_clear
  401. test_zero_set
  402. ;;; test_h_gr16 byte_src r1 ;FIXME
  403. .else
  404. mov #byte_src, er1
  405. set_ccr_zero
  406. ;; btst xx:3, ind
  407. btst #7, @er1 ; this should NOT set the zero flag.
  408. test_cc_clear
  409. btst #6, @er1 ; this should NOT set the zero flag.
  410. test_carry_clear
  411. test_ovf_clear
  412. test_neg_clear
  413. test_zero_set
  414. test_h_gr32 byte_src er1
  415. .endif ; h8300
  416. test_gr_a5a5 0 ; general registers should not be changed.
  417. test_gr_a5a5 2
  418. test_gr_a5a5 3
  419. test_gr_a5a5 4
  420. test_gr_a5a5 5
  421. test_gr_a5a5 6
  422. test_gr_a5a5 7
  423. btst_imm3_abs8:
  424. set_grs_a5a5
  425. mov.b r1l, @0x20
  426. set_ccr_zero
  427. ;; btst xx:3, aa:8
  428. btst #7, @0x20:8 ; this should NOT set the zero flag.
  429. test_cc_clear
  430. btst #6, @0x20:8 ; this should set the zero flag.
  431. test_carry_clear
  432. test_ovf_clear
  433. test_neg_clear
  434. test_zero_set
  435. test_grs_a5a5 ; general registers should not be changed.
  436. .if (sim_cpu > h8300h)
  437. btst_imm3_abs16:
  438. set_grs_a5a5
  439. set_ccr_zero
  440. ;; btst xx:3, aa:16
  441. btst #7, @byte_src:16 ; this should NOT set the zero flag.
  442. test_cc_clear
  443. btst #6, @byte_src:16 ; this should set the zero flag.
  444. test_carry_clear
  445. test_ovf_clear
  446. test_neg_clear
  447. test_zero_set
  448. test_grs_a5a5 ; general registers should not be changed.
  449. btst_imm3_abs32:
  450. set_grs_a5a5
  451. set_ccr_zero
  452. ;; btst xx:3, aa:32
  453. btst #7, @byte_src:32 ; this should NOT set the zero flag.
  454. test_cc_clear
  455. btst #6, @byte_src:32 ; this should set the zero flag.
  456. test_carry_clear
  457. test_ovf_clear
  458. test_neg_clear
  459. test_zero_set
  460. test_grs_a5a5 ; general registers should not be changed.
  461. .endif
  462. pass
  463. exit 0