biand.s 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. # Hitachi H8 testcase 'biand', 'bior', 'bixor', 'bild', 'bist', 'bistz'
  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. biand_imm3_reg8:
  16. set_grs_a5a5
  17. set_ccr_zero
  18. ;; biand xx:3, reg8
  19. biand #6, r0l ; this should NOT set the carry flag.
  20. test_cc_clear
  21. biand #7, r0l ; this should NOT set the carry flag.
  22. test_cc_clear
  23. orc #1, ccr ; set the carry flag
  24. biand #6, 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. biand #7, r0l ; this should clear the carry flag
  30. test_cc_clear
  31. test_grs_a5a5 ; general registers should not be changed.
  32. biand_imm3_ind:
  33. set_grs_a5a5
  34. .if (sim_cpu == h8300)
  35. mov #byte_src, r1
  36. set_ccr_zero
  37. ;; biand xx:3, ind
  38. biand #6, @r1 ; this should NOT set the carry flag.
  39. test_cc_clear
  40. biand #7, @r1 ; this should NOT set the carry flag.
  41. test_cc_clear
  42. orc #1, ccr ; set the carry flag
  43. biand #6, @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. biand #7, @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. ;; biand xx:3, ind
  55. biand #6, @er1 ; this should NOT set the carry flag.
  56. test_cc_clear
  57. biand #7, @er1 ; this should NOT set the carry flag.
  58. test_cc_clear
  59. orc #1, ccr ; set the carry flag
  60. biand #6, @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. biand #7, @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. biand_imm3_abs8:
  77. set_grs_a5a5
  78. mov.b r1l, @0x20
  79. set_ccr_zero
  80. ;; biand xx:3, aa:8
  81. biand #6, @0x20:8 ; this should NOT set the carry flag.
  82. test_cc_clear
  83. biand #7, @0x20:8 ; this should NOT set the carry flag.
  84. test_cc_clear
  85. orc #1, ccr ; set the carry flag
  86. biand #6, @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. biand #7, @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. biand_imm3_abs16:
  96. set_grs_a5a5
  97. set_ccr_zero
  98. ;; biand xx:3, aa:16
  99. biand #6, @byte_src:16 ; this should NOT set the carry flag.
  100. test_cc_clear
  101. biand #7, @byte_src:16 ; this should NOT set the carry flag.
  102. test_cc_clear
  103. orc #1, ccr ; set the carry flag
  104. biand #6, @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. biand #7, @byte_src:16 ; this should clear the carry flag
  110. test_cc_clear
  111. test_grs_a5a5 ; general registers should not be changed.
  112. biand_imm3_abs32:
  113. set_grs_a5a5
  114. set_ccr_zero
  115. ;; biand xx:3, aa:32
  116. biand #6, @byte_src:32 ; this should NOT set the carry flag.
  117. test_cc_clear
  118. biand #7, @byte_src:32 ; this should NOT set the carry flag.
  119. test_cc_clear
  120. orc #1, ccr ; set the carry flag
  121. biand #6, @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. biand #7, @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. bior_imm3_reg8:
  131. set_grs_a5a5
  132. set_ccr_zero
  133. ;; bior xx:3, reg8
  134. bior #7, r0l ; this should NOT set the carry flag.
  135. test_cc_clear
  136. bior #6, 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. bior #6, 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. bior #7, 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. bior_imm3_abs8:
  154. set_grs_a5a5
  155. mov.b r1l, @0x20
  156. set_ccr_zero
  157. ;; bior xx:3, aa:8
  158. bior #7, @0x20:8 ; this should NOT set the carry flag.
  159. test_cc_clear
  160. bior #6, @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. bior #6, @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. bior #7, @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. bixor_imm3_reg8:
  178. set_grs_a5a5
  179. set_ccr_zero
  180. ;; bixor xx:3, reg8
  181. bixor #7, r0l ; this should NOT set the carry flag.
  182. test_cc_clear
  183. bixor #6, 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. bixor #7, 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. bixor #6, r0l ; this should clear the carry flag
  195. test_cc_clear
  196. test_grs_a5a5 ; general registers should not be changed.
  197. bixor_imm3_abs8:
  198. set_grs_a5a5
  199. mov.b r1l, @0x20
  200. set_ccr_zero
  201. ;; bixor xx:3, aa:8
  202. bixor #7, @0x20:8 ; this should NOT set the carry flag.
  203. test_cc_clear
  204. bixor #6, @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. bixor #7, @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. bixor #6, @0x20:8 ; this should clear the carry flag
  216. test_cc_clear
  217. test_grs_a5a5 ; general registers should not be changed.
  218. bild_imm3_reg8:
  219. set_grs_a5a5
  220. set_ccr_zero
  221. ;; bild xx:3, reg8
  222. bild #7, r0l ; this should NOT set the carry flag.
  223. test_cc_clear
  224. bild #6, 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. bild_imm3_ind:
  231. set_grs_a5a5
  232. .if (sim_cpu == h8300)
  233. mov #byte_src, r1
  234. set_ccr_zero
  235. ;; bild xx:3, ind
  236. bild #7, @r1 ; this should NOT set the carry flag.
  237. test_cc_clear
  238. bild #6, @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. ;; bild xx:3, ind
  248. bild #7, @er1 ; this should NOT set the carry flag.
  249. test_cc_clear
  250. bild #6, @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. bild_imm3_abs8:
  265. set_grs_a5a5
  266. mov.b r1l, @0x20
  267. set_ccr_zero
  268. ;; bild xx:3, aa:8
  269. bild #7, @0x20:8 ; this should NOT set the carry flag.
  270. test_cc_clear
  271. bild #6, @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. bild_imm3_abs16:
  279. set_grs_a5a5
  280. set_ccr_zero
  281. ;; bild xx:3, aa:16
  282. bild #7, @byte_src:16 ; this should NOT set the carry flag.
  283. test_cc_clear
  284. bild #6, @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. bild_imm3_abs32:
  291. set_grs_a5a5
  292. set_ccr_zero
  293. ;; bild xx:3, aa:32
  294. bild #7, @byte_src:32 ; this should NOT set the carry flag.
  295. test_cc_clear
  296. bild #6, @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. bist_imm3_reg8:
  304. set_grs_a5a5
  305. set_ccr_zero
  306. ;; bist xx:3, reg8
  307. bist #6, r0l ; this should set bit 6
  308. test_cc_clear
  309. test_h_gr16 0xa5e5 r0
  310. set_ccr_zero
  311. orc #1, ccr ; set the carry flag
  312. bist #7, r0l ; this should clear bit 7
  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. bist_imm3_abs8:
  326. set_grs_a5a5
  327. mov.b r1l, @0x20
  328. set_ccr_zero
  329. ;; bist xx:3, aa:8
  330. bist #6, @0x20:8 ; this should set bit 6
  331. test_cc_clear
  332. mov.b @0x20, r0l
  333. test_h_gr16 0xa5e5 r0
  334. set_ccr_zero
  335. orc #1, ccr ; set the carry flag
  336. bist #7, @0x20:8 ; this should clear bit 7
  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. bistz_imm3_abs8:
  352. set_grs_a5a5
  353. mov.b r1l, @0x20
  354. set_ccr_zero
  355. ;; bistz xx:3, aa:8
  356. bistz #6, @0x20:8 ; this should set bit 6
  357. test_cc_clear
  358. mov.b @0x20, r0l
  359. test_h_gr16 0xa5e5 r0
  360. set_ccr_zero
  361. orc #4, ccr ; set the zero flag
  362. bistz #7, @0x20:8 ; this should clear bit 7
  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. bnot_imm3_reg8:
  378. set_grs_a5a5
  379. set_ccr_zero
  380. ;; bnot xx:3, reg8
  381. bnot #7, r0l
  382. test_cc_clear
  383. test_h_gr16 0xa525 r0
  384. set_ccr_zero
  385. bnot #6, r0l
  386. test_cc_clear
  387. test_h_gr16 0xa565 r0
  388. set_ccr_zero
  389. bnot #5, r0l
  390. test_cc_clear
  391. test_h_gr16 0xa545 r0
  392. set_ccr_zero
  393. bnot #4, r0l
  394. test_cc_clear
  395. test_h_gr16 0xa555 r0
  396. set_ccr_zero
  397. bnot #4, r0l
  398. bnot #5, r0l
  399. bnot #6, r0l
  400. bnot #7, r0l
  401. test_cc_clear
  402. test_grs_a5a5 ; general registers should not be changed.
  403. bnot_imm3_abs8:
  404. set_grs_a5a5
  405. mov.b r1l, @0x20
  406. set_ccr_zero
  407. ;; bnot xx:3, aa:8
  408. bnot #7, @0x20:8
  409. bnot #6, @0x20:8
  410. bnot #5, @0x20:8
  411. bnot #4, @0x20:8
  412. test_cc_clear
  413. test_grs_a5a5
  414. mov @0x20, r0l
  415. test_h_gr16 0xa555 r0
  416. pass
  417. exit 0