cmpb.s 23 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. # Hitachi H8 testcase 'cmp.b'
  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. # Instructions tested:
  12. # cmp.b #xx:8, rd ; a rd xxxxxxxx
  13. # cmp.b #xx:8, @erd ; 7 d rd ???? a ???? xxxxxxxx
  14. # cmp.b #xx:8, @erd+ ; 0 1 7 4 6 c rd 1??? a ???? xxxxxxxx
  15. # cmp.b #xx:8, @erd- ; 0 1 7 6 6 c rd 1??? a ???? xxxxxxxx
  16. # cmp.b #xx:8, @+erd ; 0 1 7 5 6 c rd 1??? a ???? xxxxxxxx
  17. # cmp.b #xx:8, @-erd ; 0 1 7 7 6 c rd 1??? a ???? xxxxxxxx
  18. # cmp.b rs, rd ; 1 c rs rd
  19. # cmp.b reg8, @erd ; 7 d rd ???? 1 c rs ????
  20. # cmp.b reg8, @erd+ ; 0 1 7 9 8 rd 2 rs
  21. # cmp.b reg8, @erd- ; 0 1 7 9 a rd 2 rs
  22. # cmp.b reg8, @+erd ; 0 1 7 9 9 rd 2 rs
  23. # cmp.b reg8, @-erd ; 0 1 7 9 b rd 2 rs
  24. # cmp.b rsind, rdind ; 7 c 0rs 5 0 ?rd 2 ????
  25. # cmp.b rspostinc, rdpostinc ; 0 1 7 4 6 c 0rs c 8 ?rd 2 ????
  26. # cmp.b rspostdec, rdpostdec ; 0 1 7 6 6 c 0rs c a ?rd 2 ????
  27. # cmp.b rspreinc, rdpreinc ; 0 1 7 5 6 c 0rs c 9 ?rd 2 ????
  28. # cmp.b rspredec, rdpredec ; 0 1 7 7 6 c 0rs c b ?rd 2 ????
  29. # cmp.b disp2, disp2 ; 0 1 7 01dd:2 6 8 0rs c 00dd:2 ?rd 2 ????
  30. # cmp.b disp16, disp16 ; 0 1 7 4 6 e 0rs c dd:16 c 0rd 2 ???? dd:16
  31. # cmp.b disp32, disp32 ; 7 8 0rs 4 6 a 2 c dd:32 c 1rd 2 ???? dd:32
  32. # cmp.b indexb16, indexb16 ; 0 1 7 5 6 e 0rs c dd:16 d 0rd 2 ???? dd:16
  33. # cmp.b indexw16, indexw16 ; 0 1 7 6 6 e 0rs c dd:16 e 0rd 2 ???? dd:16
  34. # cmp.b indexl16, indexl16 ; 0 1 7 7 6 e 0rs c dd:16 f 0rd 2 ???? dd:16
  35. # cmp.b indexb32, indexb32 ; 7 8 0rs 5 6 a 2 c dd:32 d 1rd 2 ???? dd:32
  36. # cmp.b indexw32, indexw32 ; 7 8 0rs 6 6 a 2 c dd:32 e 1rd 2 ???? dd:32
  37. # cmp.b indexl32, indexl32 ; 7 8 0rs 7 6 a 2 c dd:32 f 1rd 2 ???? dd:32
  38. # cmp.b abs16, abs16 ; 6 a 1 5 aa:16 4 0??? 2 ???? aa:16
  39. # cmp.b abs32, abs32 ; 6 a 3 5 aa:32 4 1??? 2 ???? aa:32
  40. #
  41. # Coming soon:
  42. # ...
  43. .data
  44. byte_src: .byte 0x5a
  45. pre_byte: .byte 0
  46. byte_dst: .byte 0xa5
  47. post_byte: .byte 0
  48. start
  49. cmp_b_imm8_reg8:
  50. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  51. ;; fixme set ccr
  52. ;; cmp.b #xx:8,Rd
  53. cmp.b #0xa5, r0l ; Immediate 8-bit src, reg8 dest
  54. beq .Leq1
  55. fail
  56. .Leq1: cmp.b #0xa6, r0l
  57. blt .Llt1
  58. fail
  59. .Llt1: cmp.b #0xa4, r0l
  60. bgt .Lgt1
  61. fail
  62. .Lgt1:
  63. ;; fixme test ccr ; H=0 N=1 Z=0 V=0 C=0
  64. test_h_gr16 0xa5a5 r0 ; r0 unchanged
  65. .if (sim_cpu) ; non-zero means h8300h, s, or sx
  66. test_h_gr32 0xa5a5a5a5 er0 ; er0 unchanged
  67. .endif
  68. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  69. test_gr_a5a5 2
  70. test_gr_a5a5 3
  71. test_gr_a5a5 4
  72. test_gr_a5a5 5
  73. test_gr_a5a5 6
  74. test_gr_a5a5 7
  75. .if (sim_cpu == h8sx)
  76. cmp_b_imm8_rdind:
  77. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  78. set_ccr_zero
  79. ;; cmp.b #xx:8,@eRd
  80. mov #byte_dst, er0
  81. cmp.b #0xa5:8, @er0 ; Immediate 8-bit src, reg indirect dst
  82. ;;; .word 0x7d00
  83. ;;; .word 0xa0a5
  84. beq .Leq2
  85. fail
  86. .Leq2: set_ccr_zero
  87. cmp.b #0xa6, @er0
  88. ;;; .word 0x7d00
  89. ;;; .word 0xa0a6
  90. blt .Llt2
  91. fail
  92. .Llt2: set_ccr_zero
  93. cmp.b #0xa4, @er0
  94. ;;; .word 0x7d00
  95. ;;; .word 0xa0a4
  96. bgt .Lgt2
  97. fail
  98. .Lgt2:
  99. test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
  100. test_ovf_clear
  101. test_zero_clear
  102. test_neg_clear
  103. test_h_gr32 byte_dst er0 ; er0 still contains address
  104. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  105. test_gr_a5a5 2
  106. test_gr_a5a5 3
  107. test_gr_a5a5 4
  108. test_gr_a5a5 5
  109. test_gr_a5a5 6
  110. test_gr_a5a5 7
  111. ;; Now check the result of the cmp to memory (memory unchanged).
  112. sub.b r0l, r0l
  113. mov.b @byte_dst, r0l
  114. cmp.b #0xa5, r0l
  115. beq .L2
  116. fail
  117. .L2:
  118. cmp_b_imm8_rdpostinc:
  119. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  120. set_ccr_zero
  121. ;; cmp.b #xx:8,@eRd+
  122. mov #byte_dst, er0
  123. cmp.b #0xa5:8, @er0+ ; Immediate 8-bit src, reg postinc dst
  124. ;;; .word 0x0174
  125. ;;; .word 0x6c08
  126. ;;; .word 0xa0a5
  127. beq .Leq3
  128. fail
  129. .Leq3: test_h_gr32 post_byte er0 ; er0 contains address plus one
  130. mov #byte_dst, er0
  131. set_ccr_zero
  132. cmp.b #0xa6, @er0+
  133. ;;; .word 0x0174
  134. ;;; .word 0x6c08
  135. ;;; .word 0xa0a6
  136. blt .Llt3
  137. fail
  138. .Llt3: test_h_gr32 post_byte er0 ; er0 contains address plus one
  139. mov #byte_dst, er0
  140. set_ccr_zero
  141. cmp.b #0xa4, @er0+
  142. ;;; .word 0x0174
  143. ;;; .word 0x6c08
  144. ;;; .word 0xa0a4
  145. bgt .Lgt3
  146. fail
  147. .Lgt3:
  148. test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
  149. test_ovf_clear
  150. test_zero_clear
  151. test_neg_clear
  152. test_h_gr32 post_byte er0 ; er0 contains address plus one
  153. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  154. test_gr_a5a5 2
  155. test_gr_a5a5 3
  156. test_gr_a5a5 4
  157. test_gr_a5a5 5
  158. test_gr_a5a5 6
  159. test_gr_a5a5 7
  160. ;; Now check the result of the cmp to memory (memory unchanged).
  161. sub.b r0l, r0l
  162. mov.b @byte_dst, r0l
  163. cmp.b #0xa5, r0l
  164. beq .L3
  165. fail
  166. .L3:
  167. cmp_b_imm8_rdpostdec:
  168. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  169. set_ccr_zero
  170. ;; cmp.b #xx:8,@eRd-
  171. mov #byte_dst, er0
  172. cmp.b #0xa5:8, @er0- ; Immediate 8-bit src, reg postdec dst
  173. ;;; .word 0x0176
  174. ;;; .word 0x6c08
  175. ;;; .word 0xa0a5
  176. beq .Leq4
  177. fail
  178. .Leq4: test_h_gr32 pre_byte er0 ; er0 contains address minus one
  179. mov #byte_dst, er0
  180. set_ccr_zero
  181. cmp.b #0xa6, @er0-
  182. ;;; .word 0x0176
  183. ;;; .word 0x6c08
  184. ;;; .word 0xa0a6
  185. blt .Llt4
  186. fail
  187. .Llt4: test_h_gr32 pre_byte er0 ; er0 contains address minus one
  188. mov #byte_dst, er0
  189. set_ccr_zero
  190. cmp.b #0xa4, @er0-
  191. ;;; .word 0x0176
  192. ;;; .word 0x6c08
  193. ;;; .word 0xa0a4
  194. bgt .Lgt4
  195. fail
  196. .Lgt4:
  197. test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
  198. test_ovf_clear
  199. test_zero_clear
  200. test_neg_clear
  201. test_h_gr32 pre_byte er0 ; er0 contains address minus one
  202. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  203. test_gr_a5a5 2
  204. test_gr_a5a5 3
  205. test_gr_a5a5 4
  206. test_gr_a5a5 5
  207. test_gr_a5a5 6
  208. test_gr_a5a5 7
  209. ;; Now check the result of the cmp to memory (memory unchanged).
  210. sub.b r0l, r0l
  211. mov.b @byte_dst, r0l
  212. cmp.b #0xa5, r0l
  213. beq .L4
  214. fail
  215. .L4:
  216. cmp_b_imm8_rdpreinc:
  217. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  218. set_ccr_zero
  219. ;; cmp.b #xx:8,@+eRd
  220. mov #pre_byte, er0
  221. cmp.b #0xa5:8, @+er0 ; Immediate 8-bit src, reg pre-inc dst
  222. ;;; .word 0x0175
  223. ;;; .word 0x6c08
  224. ;;; .word 0xa0a5
  225. beq .Leq5
  226. fail
  227. .Leq5: test_h_gr32 byte_dst er0 ; er0 contains destination address
  228. mov #pre_byte, er0
  229. set_ccr_zero
  230. cmp.b #0xa6, @+er0
  231. ;;; .word 0x0175
  232. ;;; .word 0x6c08
  233. ;;; .word 0xa0a6
  234. blt .Llt5
  235. fail
  236. .Llt5: test_h_gr32 byte_dst er0 ; er0 contains destination address
  237. mov #pre_byte, er0
  238. set_ccr_zero
  239. cmp.b #0xa4, @+er0
  240. ;;; .word 0x0175
  241. ;;; .word 0x6c08
  242. ;;; .word 0xa0a4
  243. bgt .Lgt5
  244. fail
  245. .Lgt5:
  246. test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
  247. test_ovf_clear
  248. test_zero_clear
  249. test_neg_clear
  250. test_h_gr32 byte_dst er0 ; er0 contains destination address
  251. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  252. test_gr_a5a5 2
  253. test_gr_a5a5 3
  254. test_gr_a5a5 4
  255. test_gr_a5a5 5
  256. test_gr_a5a5 6
  257. test_gr_a5a5 7
  258. ;; Now check the result of the cmp to memory (memory unchanged).
  259. sub.b r0l, r0l
  260. mov.b @byte_dst, r0l
  261. cmp.b #0xa5, r0l
  262. beq .L5
  263. fail
  264. .L5:
  265. cmp_b_imm8_rdpredec:
  266. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  267. set_ccr_zero
  268. ;; cmp.b #xx:8,@-eRd
  269. mov #post_byte, er0
  270. cmp.b #0xa5:8, @-er0 ; Immediate 8-bit src, reg pre-dec dst
  271. ;;; .word 0x0177
  272. ;;; .word 0x6c08
  273. ;;; .word 0xa0a5
  274. beq .Leq6
  275. fail
  276. .Leq6: test_h_gr32 byte_dst er0 ; er0 contains destination address
  277. mov #post_byte, er0
  278. set_ccr_zero
  279. cmp.b #0xa6, @-er0
  280. ;;; .word 0x0177
  281. ;;; .word 0x6c08
  282. ;;; .word 0xa0a6
  283. blt .Llt6
  284. fail
  285. .Llt6: test_h_gr32 byte_dst er0 ; er0 contains destination address
  286. mov #post_byte, er0
  287. set_ccr_zero
  288. cmp.b #0xa4, @-er0
  289. ;;; .word 0x0177
  290. ;;; .word 0x6c08
  291. ;;; .word 0xa0a4
  292. bgt .Lgt6
  293. fail
  294. .Lgt6:
  295. test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
  296. test_ovf_clear
  297. test_zero_clear
  298. test_neg_clear
  299. test_h_gr32 byte_dst er0 ; er0 contains destination address
  300. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  301. test_gr_a5a5 2
  302. test_gr_a5a5 3
  303. test_gr_a5a5 4
  304. test_gr_a5a5 5
  305. test_gr_a5a5 6
  306. test_gr_a5a5 7
  307. ;; Now check the result of the cmp to memory (memory unchanged).
  308. sub.b r0l, r0l
  309. mov.b @byte_dst, r0l
  310. cmp.b #0xa5, r0l
  311. beq .L6
  312. fail
  313. .L6:
  314. .endif
  315. cmp_b_reg8_reg8:
  316. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  317. ;; fixme set ccr
  318. ;; cmp.b Rs,Rd
  319. mov.b #0xa5, r0h
  320. cmp.b r0h, r0l ; Reg8 src, reg8 dst
  321. beq .Leq7
  322. fail
  323. .Leq7: mov.b #0xa6, r0h
  324. cmp.b r0h, r0l
  325. blt .Llt7
  326. fail
  327. .Llt7: mov.b #0xa4, r0h
  328. cmp.b r0h, r0l
  329. bgt .Lgt7
  330. fail
  331. .Lgt7:
  332. ;; fixme test ccr ; H=0 N=1 Z=0 V=0 C=0
  333. test_h_gr16 0xa4a5 r0 ; r0l unchanged.
  334. .if (sim_cpu) ; non-zero means h8300h, s, or sx
  335. test_h_gr32 0xa5a5a4a5 er0 ; r0l unchanged
  336. .endif
  337. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  338. test_gr_a5a5 2
  339. test_gr_a5a5 3
  340. test_gr_a5a5 4
  341. test_gr_a5a5 5
  342. test_gr_a5a5 6
  343. test_gr_a5a5 7
  344. .if (sim_cpu == h8sx)
  345. cmp_b_reg8_rdind:
  346. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  347. set_ccr_zero
  348. ;; cmp.b rs8,@eRd ; cmp reg8 to register indirect
  349. mov #byte_dst, er0
  350. mov #0xa5, r1l
  351. cmp.b r1l, @er0 ; reg8 src, reg indirect dest
  352. ;;; .word 0x7d00
  353. ;;; .word 0x1c90
  354. beq .Leq8
  355. fail
  356. .Leq8: set_ccr_zero
  357. mov #0xa6, r1l
  358. cmp.b r1l, @er0
  359. ;;; .word 0x7d00
  360. ;;; .word 0x1c90
  361. blt .Llt8
  362. fail
  363. .Llt8: set_ccr_zero
  364. mov #0xa4, r1l
  365. cmp.b r1l, @er0
  366. ;;; .word 0x7d00
  367. ;;; .word 0x1c90
  368. bgt .Lgt8
  369. fail
  370. .Lgt8:
  371. test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
  372. test_ovf_clear
  373. test_zero_clear
  374. test_neg_clear
  375. test_h_gr32 byte_dst er0 ; er0 still contains address
  376. test_h_gr32 0xa5a5a5a4 er1 ; er1 has the test load
  377. test_gr_a5a5 2 ; Make sure other general regs not disturbed
  378. test_gr_a5a5 3
  379. test_gr_a5a5 4
  380. test_gr_a5a5 5
  381. test_gr_a5a5 6
  382. test_gr_a5a5 7
  383. ;; Now check the result of the cmp to memory (no change).
  384. sub.b r0l, r0l
  385. mov.b @byte_dst, r0l
  386. cmp.b #0xa5, r0l
  387. beq .L8
  388. fail
  389. .L8:
  390. cmp_b_reg8_rdpostinc:
  391. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  392. set_ccr_zero
  393. ;; cmp.b reg8,@eRd+
  394. mov #byte_dst, er0
  395. mov #0xa5, r1l
  396. cmp.b r1l, @er0+ ; Immediate 8-bit src, reg post-incr dst
  397. ;;; .word 0x0179
  398. ;;; .word 0x8029
  399. beq .Leq9
  400. fail
  401. .Leq9: test_h_gr32 post_byte er0 ; er0 contains address plus one
  402. mov #byte_dst er0
  403. mov #0xa6, r1l
  404. set_ccr_zero
  405. cmp.b r1l, @er0+
  406. ;;; .word 0x0179
  407. ;;; .word 0x8029
  408. blt .Llt9
  409. fail
  410. .Llt9: test_h_gr32 post_byte er0 ; er0 contains address plus one
  411. mov #byte_dst er0
  412. mov #0xa4, r1l
  413. set_ccr_zero
  414. cmp.b r1l, @er0+
  415. ;;; .word 0x0179
  416. ;;; .word 0x8029
  417. bgt .Lgt9
  418. fail
  419. .Lgt9:
  420. test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
  421. test_ovf_clear
  422. test_zero_clear
  423. test_neg_clear
  424. test_h_gr32 post_byte er0 ; er0 contains address plus one
  425. test_h_gr32 0xa5a5a5a4 er1 ; er1 contains test load
  426. test_gr_a5a5 2 ; Make sure other general regs not disturbed
  427. test_gr_a5a5 3
  428. test_gr_a5a5 4
  429. test_gr_a5a5 5
  430. test_gr_a5a5 6
  431. test_gr_a5a5 7
  432. ;; Now check the result of the cmp to memory (memory unchanged).
  433. sub.b r0l, r0l
  434. mov.b @byte_dst, r0l
  435. cmp.b #0xa5, r0l
  436. beq .L9
  437. fail
  438. .L9:
  439. ;; special case same register
  440. mov.l #byte_dst, er0
  441. mov.b @er0, r1h
  442. mov.b r0l, r1l
  443. inc.b r1l
  444. mov.b r1l,@er0
  445. cmp.b r0l,@er0+
  446. beq .L19
  447. fail
  448. .L19:
  449. mov.b r1h, @byte_dst
  450. cmp_b_reg8_rdpostdec:
  451. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  452. set_ccr_zero
  453. ;; cmp.b reg8,@eRd-
  454. mov #byte_dst, er0
  455. mov #0xa5, r1l
  456. cmp.b r1l, @er0- ; Immediate 8-bit src, reg postdec dst
  457. ;;; .word 0x0179
  458. ;;; .word 0xa029
  459. beq .Leq10
  460. fail
  461. .Leq10: test_h_gr32 pre_byte er0 ; er0 contains address minus one
  462. mov #byte_dst er0
  463. mov #0xa6, r1l
  464. set_ccr_zero
  465. cmp.b r1l, @er0-
  466. ;;; .word 0x0179
  467. ;;; .word 0xa029
  468. blt .Llt10
  469. fail
  470. .Llt10: test_h_gr32 pre_byte er0 ; er0 contains address minus one
  471. mov #byte_dst er0
  472. mov #0xa4, r1l
  473. set_ccr_zero
  474. cmp.b r1l, @er0-
  475. ;;; .word 0x0179
  476. ;;; .word 0xa029
  477. bgt .Lgt10
  478. fail
  479. .Lgt10:
  480. test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
  481. test_ovf_clear
  482. test_zero_clear
  483. test_neg_clear
  484. test_h_gr32 pre_byte er0 ; er0 contains address minus one
  485. test_h_gr32 0xa5a5a5a4 er1 ; er1 contains test load
  486. test_gr_a5a5 2 ; Make sure other general regs not disturbed
  487. test_gr_a5a5 3
  488. test_gr_a5a5 4
  489. test_gr_a5a5 5
  490. test_gr_a5a5 6
  491. test_gr_a5a5 7
  492. ;; Now check the result of the cmp to memory (memory unchanged).
  493. sub.b r0l, r0l
  494. mov.b @byte_dst, r0l
  495. cmp.b #0xa5, r0l
  496. beq .L10
  497. fail
  498. .L10:
  499. ;; special case same register
  500. mov.l #byte_dst, er0
  501. mov.b @er0, r1h
  502. mov.b r0l, r1l
  503. dec.b r1l
  504. mov.b r1l,@er0
  505. cmp.b r0l,@er0-
  506. beq .L20
  507. fail
  508. .L20:
  509. mov.b r1h, @byte_dst
  510. cmp_b_reg8_rdpreinc:
  511. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  512. set_ccr_zero
  513. ;; cmp.b reg8,@+eRd
  514. mov #pre_byte, er0
  515. mov #0xa5, r1l
  516. cmp.b r1l, @+er0 ; Immediate 8-bit src, reg post-incr dst
  517. ;;; .word 0x0179
  518. ;;; .word 0x9029
  519. beq .Leq11
  520. fail
  521. .Leq11: test_h_gr32 byte_dst er0 ; er0 contains destination address
  522. mov #pre_byte er0
  523. mov #0xa6, r1l
  524. set_ccr_zero
  525. cmp.b r1l, @+er0
  526. ;;; .word 0x0179
  527. ;;; .word 0x9029
  528. blt .Llt11
  529. fail
  530. .Llt11: test_h_gr32 byte_dst er0 ; er0 contains destination address
  531. mov #pre_byte er0
  532. mov #0xa4, r1l
  533. set_ccr_zero
  534. cmp.b r1l, @+er0
  535. ;;; .word 0x0179
  536. ;;; .word 0x9029
  537. bgt .Lgt11
  538. fail
  539. .Lgt11:
  540. test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
  541. test_ovf_clear
  542. test_zero_clear
  543. test_neg_clear
  544. test_h_gr32 byte_dst er0 ; er0 contains destination address
  545. test_h_gr32 0xa5a5a5a4 er1 ; er1 contains test load
  546. test_gr_a5a5 2 ; Make sure other general regs not disturbed
  547. test_gr_a5a5 3
  548. test_gr_a5a5 4
  549. test_gr_a5a5 5
  550. test_gr_a5a5 6
  551. test_gr_a5a5 7
  552. ;; Now check the result of the cmp to memory (memory unchanged).
  553. sub.b r0l, r0l
  554. mov.b @byte_dst, r0l
  555. cmp.b #0xa5, r0l
  556. beq .L11
  557. fail
  558. .L11:
  559. ;; special case same register
  560. mov.l #pre_byte, er0
  561. mov.b @byte_dst, r1h
  562. mov.b r0l, r1l
  563. inc.b r1l
  564. mov.b r1l,@(1,er0)
  565. cmp.b r0l,@+er0
  566. beq .L21
  567. fail
  568. .L21:
  569. mov.b r1h, @byte_dst
  570. cmp_b_reg8_rdpredec:
  571. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  572. set_ccr_zero
  573. ;; cmp.b reg8,@-eRd
  574. mov #post_byte, er0
  575. mov #0xa5, r1l
  576. cmp.b r1l, @-er0 ; Immediate 8-bit src, reg postdec dst
  577. ;;; .word 0x0179
  578. ;;; .word 0xb029
  579. beq .Leq12
  580. fail
  581. .Leq12: test_h_gr32 byte_dst er0 ; er0 contains destination address
  582. mov #post_byte er0
  583. mov #0xa6, r1l
  584. set_ccr_zero
  585. cmp.b r1l, @-er0
  586. ;;; .word 0x0179
  587. ;;; .word 0xb029
  588. blt .Llt12
  589. fail
  590. .Llt12: test_h_gr32 byte_dst er0 ; er0 contains destination address
  591. mov #post_byte er0
  592. mov #0xa4, r1l
  593. set_ccr_zero
  594. cmp.b r1l, @-er0
  595. ;;; .word 0x0179
  596. ;;; .word 0xb029
  597. bgt .Lgt12
  598. fail
  599. .Lgt12:
  600. test_carry_clear ; H=0 N=0 Z=0 V=0 C=0
  601. test_ovf_clear
  602. test_zero_clear
  603. test_neg_clear
  604. test_h_gr32 byte_dst er0 ; er0 contains destination address
  605. test_h_gr32 0xa5a5a5a4 er1 ; er1 contains test load
  606. test_gr_a5a5 2 ; Make sure other general regs not disturbed
  607. test_gr_a5a5 3
  608. test_gr_a5a5 4
  609. test_gr_a5a5 5
  610. test_gr_a5a5 6
  611. test_gr_a5a5 7
  612. ;; Now check the result of the cmp to memory (memory unchanged).
  613. sub.b r0l, r0l
  614. mov.b @byte_dst, r0l
  615. cmp.b #0xa5, r0l
  616. beq .L12
  617. fail
  618. .L12:
  619. ;; special case same register
  620. mov.l #post_byte, er0
  621. mov.b @byte_dst, r1h
  622. mov.b r0l, r1l
  623. dec.b r1l
  624. mov.b r1l,@(-1,er0)
  625. cmp.b r0l,@-er0
  626. beq .L22
  627. fail
  628. .L22:
  629. mov.b r1h, @byte_dst
  630. cmp_b_rsind_rdind:
  631. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  632. mov #byte_src, er1
  633. mov #byte_dst, er2
  634. set_ccr_zero
  635. cmp.b @er1, @er2
  636. test_neg_clear ; N=0, Z=0, V=1, C=0
  637. test_zero_clear
  638. test_ovf_set
  639. test_carry_clear
  640. test_gr_a5a5 0
  641. test_h_gr32 byte_src er1
  642. test_h_gr32 byte_dst er2
  643. test_gr_a5a5 3
  644. test_gr_a5a5 4
  645. test_gr_a5a5 5
  646. test_gr_a5a5 6
  647. test_gr_a5a5 7
  648. cmp.b #0x5a, @byte_src:16
  649. bne fail1
  650. cmp.b #0xa5, @byte_dst:16
  651. bne fail1
  652. .if 1 ; ambiguous
  653. cmp_b_rspostinc_rdpostinc:
  654. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  655. mov #byte_src, er1
  656. mov #byte_dst, er2
  657. set_ccr_zero
  658. cmp.b @er1+, @er2+
  659. ;;; .word 0x0174
  660. ;;; .word 0x6c1c
  661. ;;; .word 0x8220
  662. test_neg_clear ; N=0, Z=0, V=1, C=0
  663. test_zero_clear
  664. test_ovf_set
  665. test_carry_clear
  666. test_gr_a5a5 0
  667. test_h_gr32 byte_src+1 er1
  668. test_h_gr32 byte_dst+1 er2
  669. test_gr_a5a5 3
  670. test_gr_a5a5 4
  671. test_gr_a5a5 5
  672. test_gr_a5a5 6
  673. test_gr_a5a5 7
  674. cmp.b #0x5a, @byte_src:16
  675. bne fail1
  676. cmp.b #0xa5, @byte_dst:16
  677. bne fail1
  678. .endif
  679. .if 1 ; ambiguous
  680. cmp_b_rspostdec_rdpostdec:
  681. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  682. mov #byte_src, er1
  683. mov #byte_dst, er2
  684. set_ccr_zero
  685. cmp.b @er1-, @er2-
  686. ;;; .word 0x0176
  687. ;;; .word 0x6c1c
  688. ;;; .word 0xa220
  689. test_neg_clear ; N=0, Z=0, V=1, C=0
  690. test_zero_clear
  691. test_ovf_set
  692. test_carry_clear
  693. test_gr_a5a5 0
  694. test_h_gr32 byte_src-1 er1
  695. test_h_gr32 byte_dst-1 er2
  696. test_gr_a5a5 3
  697. test_gr_a5a5 4
  698. test_gr_a5a5 5
  699. test_gr_a5a5 6
  700. test_gr_a5a5 7
  701. cmp.b #0x5a, @byte_src:16
  702. bne fail1
  703. cmp.b #0xa5, @byte_dst:16
  704. bne fail1
  705. .endif
  706. cmp_b_rspreinc_rdpreinc:
  707. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  708. mov #byte_src-1, er1
  709. mov #byte_dst-1, er2
  710. set_ccr_zero
  711. cmp.b @+er1, @+er2
  712. ;;; .word 0x0175
  713. ;;; .word 0x6c1c
  714. ;;; .word 0x9220
  715. test_neg_clear ; N=0, Z=0, V=1, C=0
  716. test_zero_clear
  717. test_ovf_set
  718. test_carry_clear
  719. test_gr_a5a5 0
  720. test_h_gr32 byte_src er1
  721. test_h_gr32 byte_dst er2
  722. test_gr_a5a5 3
  723. test_gr_a5a5 4
  724. test_gr_a5a5 5
  725. test_gr_a5a5 6
  726. test_gr_a5a5 7
  727. cmp.b #0x5a, @byte_src:16
  728. bne fail1
  729. cmp.b #0xa5, @byte_dst:16
  730. bne fail1
  731. cmp_b_rspredec_predec:
  732. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  733. mov #byte_src+1, er1
  734. mov #byte_dst+1, er2
  735. set_ccr_zero
  736. cmp.b @-er1, @-er2
  737. ;;; .word 0x0177
  738. ;;; .word 0x6c1c
  739. ;;; .word 0xb220
  740. test_neg_clear ; N=0, Z=0, V=1, C=0
  741. test_zero_clear
  742. test_ovf_set
  743. test_carry_clear
  744. test_gr_a5a5 0
  745. test_h_gr32 byte_src er1
  746. test_h_gr32 byte_dst er2
  747. test_gr_a5a5 3
  748. test_gr_a5a5 4
  749. test_gr_a5a5 5
  750. test_gr_a5a5 6
  751. test_gr_a5a5 7
  752. cmp.b #0x5a, @byte_src:16
  753. bne fail1
  754. cmp.b #0xa5, @byte_dst:16
  755. bne fail1
  756. cmp_b_disp2_disp2:
  757. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  758. mov #byte_src-1, er1
  759. mov #byte_dst-2, er2
  760. set_ccr_zero
  761. cmp.b @(1:2, er1), @(2:2, er2)
  762. ;;; .word 0x0175
  763. ;;; .word 0x681c
  764. ;;; .word 0x2220
  765. test_neg_clear ; N=0, Z=0, V=1, C=0
  766. test_zero_clear
  767. test_ovf_set
  768. test_carry_clear
  769. test_gr_a5a5 0
  770. test_h_gr32 byte_src-1 er1
  771. test_h_gr32 byte_dst-2 er2
  772. test_gr_a5a5 3
  773. test_gr_a5a5 4
  774. test_gr_a5a5 5
  775. test_gr_a5a5 6
  776. test_gr_a5a5 7
  777. cmp.b #0x5a, @byte_src:16
  778. bne fail1
  779. cmp.b #0xa5, @byte_dst:16
  780. bne fail1
  781. cmp_b_disp16_disp16:
  782. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  783. mov #byte_src-3, er1
  784. mov #byte_dst-4, er2
  785. set_ccr_zero
  786. cmp.b @(3:16, er1), @(4:16, er2)
  787. ;;; .word 0x0174
  788. ;;; .word 0x6e1c
  789. ;;; .word 3
  790. ;;; .word 0xc220
  791. ;;; .word 4
  792. test_neg_clear ; N=0, Z=0, V=1, C=0
  793. test_zero_clear
  794. test_ovf_set
  795. test_carry_clear
  796. test_gr_a5a5 0
  797. test_h_gr32 byte_src-3 er1
  798. test_h_gr32 byte_dst-4 er2
  799. test_gr_a5a5 3
  800. test_gr_a5a5 4
  801. test_gr_a5a5 5
  802. test_gr_a5a5 6
  803. test_gr_a5a5 7
  804. cmp.b #0x5a, @byte_src:16
  805. bne fail1
  806. cmp.b #0xa5, @byte_dst:16
  807. bne fail1
  808. cmp_b_disp32_disp32:
  809. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  810. mov #byte_src+5, er1
  811. mov #byte_dst+6, er2
  812. set_ccr_zero
  813. cmp.b @(-5:32, er1), @(-6:32, er2)
  814. ;;; .word 0x7814
  815. ;;; .word 0x6a2c
  816. ;;; .long -5
  817. ;;; .word 0xca20
  818. ;;; .long -6
  819. test_neg_clear ; N=0, Z=0, V=1, C=0
  820. test_zero_clear
  821. test_ovf_set
  822. test_carry_clear
  823. test_gr_a5a5 0
  824. test_h_gr32 byte_src+5 er1
  825. test_h_gr32 byte_dst+6 er2
  826. test_gr_a5a5 3
  827. test_gr_a5a5 4
  828. test_gr_a5a5 5
  829. test_gr_a5a5 6
  830. test_gr_a5a5 7
  831. cmp.b #0x5a, @byte_src:16
  832. bne fail1
  833. cmp.b #0xa5, @byte_dst:16
  834. bne fail1
  835. cmp_b_indexb16_indexb16:
  836. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  837. mov #0xffffff01, er1
  838. mov #0xffffff02, er2
  839. set_ccr_zero
  840. cmp.b @(byte_src-1:16, r1.b), @(byte_dst-2:16, r2.b)
  841. ;;; .word 0x0175
  842. ;;; .word 0x6e1c
  843. ;;; .word byte_src-1
  844. ;;; .word 0xd220
  845. ;;; .word byte_dst-2
  846. test_neg_clear ; N=0, Z=0, V=1, C=0
  847. test_zero_clear
  848. test_ovf_set
  849. test_carry_clear
  850. test_gr_a5a5 0
  851. test_h_gr32 0xffffff01 er1
  852. test_h_gr32 0xffffff02 er2
  853. test_gr_a5a5 3
  854. test_gr_a5a5 4
  855. test_gr_a5a5 5
  856. test_gr_a5a5 6
  857. test_gr_a5a5 7
  858. cmp.b #0x5a, @byte_src:16
  859. bne fail1
  860. cmp.b #0xa5, @byte_dst:16
  861. bne fail1
  862. .if 1 ; ambiguous
  863. cmp_b_indexw16_indexw16:
  864. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  865. mov #0xffff0003, er1
  866. mov #0xffff0004, er2
  867. set_ccr_zero
  868. cmp.b @(byte_src-3:16, r1.w), @(byte_dst-4:16, r2.w)
  869. ;;; .word 0x0176
  870. ;;; .word 0x6e1c
  871. ;;; .word byte_src-3
  872. ;;; .word 0xe220
  873. ;;; .word byte_dst-4
  874. test_neg_clear ; N=0, Z=0, V=1, C=0
  875. test_zero_clear
  876. test_ovf_set
  877. test_carry_clear
  878. test_gr_a5a5 0
  879. test_h_gr32 0xffff0003 er1
  880. test_h_gr32 0xffff0004 er2
  881. test_gr_a5a5 3
  882. test_gr_a5a5 4
  883. test_gr_a5a5 5
  884. test_gr_a5a5 6
  885. test_gr_a5a5 7
  886. cmp.b #0x5a, @byte_src:16
  887. bne fail1
  888. cmp.b #0xa5, @byte_dst:16
  889. bne fail1
  890. .endif
  891. cmp_b_indexl16_indexl16:
  892. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  893. mov #0x00000005, er1
  894. mov #0x00000006, er2
  895. set_ccr_zero
  896. cmp.b @(byte_src-5:16, er1.l), @(byte_dst-6:16, er2.l)
  897. ;;; .word 0x0177
  898. ;;; .word 0x6e1c
  899. ;;; .word byte_src-5
  900. ;;; .word 0xf220
  901. ;;; .word byte_dst-6
  902. test_neg_clear ; N=0, Z=0, V=1, C=0
  903. test_zero_clear
  904. test_ovf_set
  905. test_carry_clear
  906. test_gr_a5a5 0
  907. test_h_gr32 0x00000005 er1
  908. test_h_gr32 0x00000006 er2
  909. test_gr_a5a5 3
  910. test_gr_a5a5 4
  911. test_gr_a5a5 5
  912. test_gr_a5a5 6
  913. test_gr_a5a5 7
  914. cmp.b #0x5a, @byte_src:16
  915. bne fail1
  916. cmp.b #0xa5, @byte_dst:16
  917. bne fail1
  918. cmp_b_indexb32_indexb32:
  919. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  920. mov #0xffffff01, er1
  921. mov #0xffffff02, er2
  922. set_ccr_zero
  923. cmp.b @(byte_src-1:32, r1.b), @(byte_dst-2:32, r2.b)
  924. ;;; .word 0x7815
  925. ;;; .word 0x6a2c
  926. ;;; .long byte_src-1
  927. ;;; .word 0xda20
  928. ;;; .long byte_dst-2
  929. test_neg_clear ; N=0, Z=0, V=1, C=0
  930. test_zero_clear
  931. test_ovf_set
  932. test_carry_clear
  933. test_gr_a5a5 0
  934. test_h_gr32 0xffffff01 er1
  935. test_h_gr32 0xffffff02 er2
  936. test_gr_a5a5 3
  937. test_gr_a5a5 4
  938. test_gr_a5a5 5
  939. test_gr_a5a5 6
  940. test_gr_a5a5 7
  941. cmp.b #0x5a, @byte_src:16
  942. bne fail1
  943. cmp.b #0xa5, @byte_dst:16
  944. bne fail1
  945. .if 1 ; ambiguous
  946. cmp_b_indexw32_indexw32:
  947. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  948. mov #0xffff0003, er1
  949. mov #0xffff0004, er2
  950. set_ccr_zero
  951. cmp.b @(byte_src-3:32, r1.w), @(byte_dst-4:32, r2.w)
  952. ;;; .word 0x7816
  953. ;;; .word 0x6a2c
  954. ;;; .long byte_src-3
  955. ;;; .word 0xea20
  956. ;;; .long byte_dst-4
  957. test_neg_clear ; N=0, Z=0, V=1, C=0
  958. test_zero_clear
  959. test_ovf_set
  960. test_carry_clear
  961. test_gr_a5a5 0
  962. test_h_gr32 0xffff0003 er1
  963. test_h_gr32 0xffff0004 er2
  964. test_gr_a5a5 3
  965. test_gr_a5a5 4
  966. test_gr_a5a5 5
  967. test_gr_a5a5 6
  968. test_gr_a5a5 7
  969. cmp.b #0x5a, @byte_src:16
  970. bne fail1
  971. cmp.b #0xa5, @byte_dst:16
  972. bne fail1
  973. .endif
  974. cmp_b_indexl32_indexl32:
  975. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  976. mov #0x00000005, er1
  977. mov #0x00000006, er2
  978. set_ccr_zero
  979. cmp.b @(byte_src-5:32, er1.l), @(byte_dst-6:32, er2.l)
  980. ;;; .word 0x7817
  981. ;;; .word 0x6a2c
  982. ;;; .long byte_src-5
  983. ;;; .word 0xfa20
  984. ;;; .long byte_dst-6
  985. test_neg_clear ; N=0, Z=0, V=1, C=0
  986. test_zero_clear
  987. test_ovf_set
  988. test_carry_clear
  989. test_gr_a5a5 0
  990. test_h_gr32 0x00000005 er1
  991. test_h_gr32 0x00000006 er2
  992. test_gr_a5a5 3
  993. test_gr_a5a5 4
  994. test_gr_a5a5 5
  995. test_gr_a5a5 6
  996. test_gr_a5a5 7
  997. cmp.b #0x5a, @byte_src:16
  998. bne fail1
  999. cmp.b #0xa5, @byte_dst:16
  1000. bne fail1
  1001. cmp_b_abs16_abs16:
  1002. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  1003. set_ccr_zero
  1004. cmp.b @byte_src:16, @byte_dst:16
  1005. test_neg_clear ; N=0, Z=0, V=1, C=0
  1006. test_zero_clear
  1007. test_ovf_set
  1008. test_carry_clear
  1009. test_grs_a5a5
  1010. cmp.b #0x5a, @byte_src:16
  1011. bne fail1
  1012. cmp.b #0xa5, @byte_dst:16
  1013. bne fail1
  1014. cmp_b_abs32_abs32:
  1015. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  1016. set_ccr_zero
  1017. cmp.b @byte_src:32, @byte_dst:32
  1018. test_neg_clear ; N=0, Z=0, V=1, C=0
  1019. test_zero_clear
  1020. test_ovf_set
  1021. test_carry_clear
  1022. test_grs_a5a5
  1023. cmp.b #0x5a, @byte_src:16
  1024. bne fail1
  1025. cmp.b #0xa5, @byte_dst:16
  1026. bne fail1
  1027. .endif
  1028. pass
  1029. exit 0
  1030. fail1: fail