neg.s 20 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022
  1. # Hitachi H8 testcase 'neg.b, neg.w, neg.l'
  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. # neg.b rd ; 1 7 8 rd
  13. # neg.b @erd ; 7 d rd ???? 1 7 8 ignore
  14. # neg.b @erd+ ; 0 1 7 4 6 c rd 1??? 1 7 8 ignore
  15. # neg.b @erd- ; 0 1 7 6 6 c rd 1??? 1 7 8 ignore
  16. # neg.b @+erd ; 0 1 7 5 6 c rd 1??? 1 7 8 ignore
  17. # neg.b @-erd ; 0 1 7 7 6 c rd 1??? 1 7 8 ignore
  18. # neg.b @(d:2, erd) ; 0 1 7 01dd 6 8 rd 8 1 7 8 ignore
  19. # neg.b @(d:16, erd) ; 0 1 7 4 6 e rd 1??? dd:16 1 7 8 ignore
  20. # neg.b @(d:32, erd) ; 7 8 rd 4 6 a 2 1??? dd:32 1 7 8 ignore
  21. # neg.b @aa:16 ; 6 a 1 1??? aa:16 1 7 8 ignore
  22. # neg.b @aa:32 ; 6 a 3 1??? aa:32 1 7 8 ignore
  23. # word operations
  24. # long operations
  25. #
  26. # Coming soon:
  27. # neg.b @aa:8 ; 7 f aaaaaaaa 1 7 8 ignore
  28. #
  29. .data
  30. byte_dest: .byte 0xa5
  31. .align 2
  32. word_dest: .word 0xa5a5
  33. .align 4
  34. long_dest: .long 0xa5a5a5a5
  35. start
  36. #
  37. # Note: apparently carry is set for neg of anything except zero.
  38. #
  39. #
  40. # 8-bit byte operations
  41. #
  42. neg_b_reg8:
  43. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  44. set_ccr_zero
  45. ;; neg.b Rd
  46. neg r0l ; 8-bit register
  47. ;;; .word 0x1788
  48. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  49. test_ovf_clear
  50. test_zero_clear
  51. test_neg_clear
  52. cmp.b #0x5b, r0l ; result of "neg 0xa5"
  53. beq .Lbrd
  54. fail
  55. .Lbrd:
  56. test_h_gr16 0xa55b r0 ; r0 changed by 'neg'
  57. .if (sim_cpu) ; non-zero means h8300h, s, or sx
  58. test_h_gr32 0xa5a5a55b er0 ; er0 changed by 'neg'
  59. .endif
  60. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  61. test_gr_a5a5 2
  62. test_gr_a5a5 3
  63. test_gr_a5a5 4
  64. test_gr_a5a5 5
  65. test_gr_a5a5 6
  66. test_gr_a5a5 7
  67. .if (sim_cpu == h8sx)
  68. neg_b_rdind:
  69. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  70. set_ccr_zero
  71. ;; neg.b @eRd
  72. mov #byte_dest, er0
  73. neg.b @er0 ; register indirect operand
  74. ;;; .word 0x7d00
  75. ;;; .word 0x1780
  76. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  77. test_ovf_clear
  78. test_zero_clear
  79. test_neg_clear
  80. test_h_gr32 byte_dest er0 ; er0 still contains address
  81. cmp.b #0x5b, @er0 ; memory contents changed
  82. beq .Lbind
  83. fail
  84. .Lbind:
  85. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  86. test_gr_a5a5 2
  87. test_gr_a5a5 3
  88. test_gr_a5a5 4
  89. test_gr_a5a5 5
  90. test_gr_a5a5 6
  91. test_gr_a5a5 7
  92. neg_b_rdpostinc:
  93. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  94. set_ccr_zero
  95. ;; neg.b @eRd+
  96. mov #byte_dest, er0 ; register post-increment operand
  97. neg.b @er0+
  98. ;;; .word 0x0174
  99. ;;; .word 0x6c08
  100. ;;; .word 0x1780
  101. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  102. test_ovf_clear
  103. test_zero_clear
  104. test_neg_set
  105. test_h_gr32 byte_dest+1 er0 ; er0 contains address plus one
  106. cmp.b #0xa5, @-er0
  107. beq .Lbpostinc
  108. fail
  109. .Lbpostinc:
  110. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  111. test_gr_a5a5 2
  112. test_gr_a5a5 3
  113. test_gr_a5a5 4
  114. test_gr_a5a5 5
  115. test_gr_a5a5 6
  116. test_gr_a5a5 7
  117. neg_b_rdpostdec:
  118. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  119. set_ccr_zero
  120. ;; neg.b @eRd-
  121. mov #byte_dest, er0 ; register post-decrement operand
  122. neg.b @er0-
  123. ;;; .word 0x0176
  124. ;;; .word 0x6c08
  125. ;;; .word 0x1780
  126. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  127. test_ovf_clear
  128. test_zero_clear
  129. test_neg_clear
  130. test_h_gr32 byte_dest-1 er0 ; er0 contains address minus one
  131. cmp.b #0x5b, @+er0
  132. beq .Lbpostdec
  133. fail
  134. .Lbpostdec:
  135. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  136. test_gr_a5a5 2
  137. test_gr_a5a5 3
  138. test_gr_a5a5 4
  139. test_gr_a5a5 5
  140. test_gr_a5a5 6
  141. test_gr_a5a5 7
  142. neg_b_rdpreinc:
  143. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  144. set_ccr_zero
  145. ;; neg.b @+eRd
  146. mov #byte_dest-1, er0
  147. neg.b @+er0 ; reg pre-increment operand
  148. ;;; .word 0x0175
  149. ;;; .word 0x6c08
  150. ;;; .word 0x1780
  151. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  152. test_ovf_clear
  153. test_zero_clear
  154. test_neg_set
  155. cmp.b #0xa5, @er0
  156. beq .Lbpreinc
  157. fail
  158. .Lbpreinc:
  159. test_h_gr32 byte_dest er0 ; er0 contains destination address
  160. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  161. test_gr_a5a5 2
  162. test_gr_a5a5 3
  163. test_gr_a5a5 4
  164. test_gr_a5a5 5
  165. test_gr_a5a5 6
  166. test_gr_a5a5 7
  167. neg_b_rdpredec:
  168. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  169. set_ccr_zero
  170. ;; neg.b @-eRd
  171. mov #byte_dest+1, er0
  172. neg.b @-er0 ; reg pre-decr operand
  173. ;;; .word 0x0177
  174. ;;; .word 0x6c08
  175. ;;; .word 0x1780
  176. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  177. test_ovf_clear
  178. test_zero_clear
  179. test_neg_clear
  180. cmp.b #0x5b, @er0
  181. beq .Lbpredec
  182. fail
  183. .Lbpredec:
  184. test_h_gr32 byte_dest er0 ; er0 contains destination address
  185. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  186. test_gr_a5a5 2
  187. test_gr_a5a5 3
  188. test_gr_a5a5 4
  189. test_gr_a5a5 5
  190. test_gr_a5a5 6
  191. test_gr_a5a5 7
  192. neg_b_disp2dst:
  193. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  194. set_ccr_zero
  195. ;; neg.b @(dd:2, erd)
  196. mov #byte_dest-1, er0
  197. neg.b @(1:2, er0) ; reg plus 2-bit displacement
  198. ;;; .word 0x0175
  199. ;;; .word 0x6808
  200. ;;; .word 0x1780
  201. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  202. test_ovf_clear
  203. test_zero_clear
  204. test_neg_set
  205. cmp.b #0xa5, @+er0
  206. beq .Lbdisp2
  207. fail
  208. .Lbdisp2:
  209. test_h_gr32 byte_dest er0 ; er0 contains destination address
  210. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  211. test_gr_a5a5 2
  212. test_gr_a5a5 3
  213. test_gr_a5a5 4
  214. test_gr_a5a5 5
  215. test_gr_a5a5 6
  216. test_gr_a5a5 7
  217. neg_b_disp16dst:
  218. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  219. set_ccr_zero
  220. ;; neg.b @(dd:16, erd)
  221. mov #byte_dest+100, er0
  222. neg.b @(-100:16, er0) ; reg plus 16-bit displacement
  223. ;;; .word 0x0174
  224. ;;; .word 0x6e08
  225. ;;; .word -100
  226. ;;; .word 0x1780
  227. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  228. test_ovf_clear
  229. test_zero_clear
  230. test_neg_clear
  231. cmp.b #0x5b, @byte_dest
  232. beq .Lbdisp16
  233. fail
  234. .Lbdisp16:
  235. test_h_gr32 byte_dest+100 er0 ; er0 contains destination address
  236. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  237. test_gr_a5a5 2
  238. test_gr_a5a5 3
  239. test_gr_a5a5 4
  240. test_gr_a5a5 5
  241. test_gr_a5a5 6
  242. test_gr_a5a5 7
  243. neg_b_disp32dst:
  244. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  245. set_ccr_zero
  246. ;; neg.b @(dd:32, erd)
  247. mov #byte_dest-0xfffff, er0
  248. neg.b @(0xfffff:32, er0) ; reg plus 32-bit displacement
  249. ;;; .word 0x7804
  250. ;;; .word 0x6a28
  251. ;;; .long 0xfffff
  252. ;;; .word 0x1780
  253. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  254. test_ovf_clear
  255. test_zero_clear
  256. test_neg_set
  257. cmp.b #0xa5, @byte_dest
  258. beq .Lbdisp32
  259. fail
  260. .Lbdisp32:
  261. test_h_gr32 byte_dest-0xfffff er0 ; er0 contains destination address
  262. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  263. test_gr_a5a5 2
  264. test_gr_a5a5 3
  265. test_gr_a5a5 4
  266. test_gr_a5a5 5
  267. test_gr_a5a5 6
  268. test_gr_a5a5 7
  269. neg_b_abs16dst:
  270. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  271. set_ccr_zero
  272. ;; neg.b @aa:16
  273. neg.b @byte_dest:16 ; 16-bit absolute address
  274. ;;; .word 0x6a18
  275. ;;; .word byte_dest
  276. ;;; .word 0x1780
  277. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  278. test_ovf_clear
  279. test_zero_clear
  280. test_neg_clear
  281. cmp.b #0x5b, @byte_dest
  282. beq .Lbabs16
  283. fail
  284. .Lbabs16:
  285. test_gr_a5a5 0 ; Make sure ALL general regs not disturbed
  286. test_gr_a5a5 1
  287. test_gr_a5a5 2
  288. test_gr_a5a5 3
  289. test_gr_a5a5 4
  290. test_gr_a5a5 5
  291. test_gr_a5a5 6
  292. test_gr_a5a5 7
  293. neg_b_abs32dst:
  294. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  295. set_ccr_zero
  296. ;; neg.b @aa:32
  297. neg.b @byte_dest:32 ; 32-bit absolute address
  298. ;;; .word 0x6a38
  299. ;;; .long byte_dest
  300. ;;; .word 0x1780
  301. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  302. test_ovf_clear
  303. test_zero_clear
  304. test_neg_set
  305. cmp.b #0xa5, @byte_dest
  306. beq .Lbabs32
  307. fail
  308. .Lbabs32:
  309. test_gr_a5a5 0 ; Make sure ALL general regs not disturbed
  310. test_gr_a5a5 1
  311. test_gr_a5a5 2
  312. test_gr_a5a5 3
  313. test_gr_a5a5 4
  314. test_gr_a5a5 5
  315. test_gr_a5a5 6
  316. test_gr_a5a5 7
  317. .endif
  318. #
  319. # 16-bit word operations
  320. #
  321. .if (sim_cpu) ; any except plain-vanilla h8/300
  322. neg_w_reg16:
  323. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  324. set_ccr_zero
  325. ;; neg.w Rd
  326. neg r1 ; 16-bit register operand
  327. ;;; .word 0x1791
  328. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  329. test_ovf_clear
  330. test_zero_clear
  331. test_neg_clear
  332. cmp.w #0x5a5b, r1 ; result of "neg 0xa5a5"
  333. beq .Lwrd
  334. fail
  335. .Lwrd:
  336. test_h_gr32 0xa5a55a5b er1 ; er1 changed by 'neg'
  337. test_gr_a5a5 0 ; 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. neg_w_rdind:
  346. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  347. set_ccr_zero
  348. ;; neg.w @eRd
  349. mov #word_dest, er1
  350. neg.w @er1 ; register indirect operand
  351. ;;; .word 0x0154
  352. ;;; .word 0x6d18
  353. ;;; .word 0x1790
  354. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  355. test_ovf_clear
  356. test_zero_clear
  357. test_neg_clear
  358. cmp.w #0x5a5b, @word_dest ; memory contents changed
  359. beq .Lwind
  360. fail
  361. .Lwind:
  362. test_h_gr32 word_dest er1 ; er1 still contains address
  363. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  364. test_gr_a5a5 2
  365. test_gr_a5a5 3
  366. test_gr_a5a5 4
  367. test_gr_a5a5 5
  368. test_gr_a5a5 6
  369. test_gr_a5a5 7
  370. neg_w_rdpostinc:
  371. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  372. set_ccr_zero
  373. ;; neg.w @eRd+
  374. mov #word_dest, er1 ; register post-increment operand
  375. neg.w @er1+
  376. ;;; .word 0x0154
  377. ;;; .word 0x6d18
  378. ;;; .word 0x1790
  379. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  380. test_ovf_clear
  381. test_zero_clear
  382. test_neg_set
  383. cmp.w #0xa5a5, @word_dest
  384. beq .Lwpostinc
  385. fail
  386. .Lwpostinc:
  387. test_h_gr32 word_dest+2 er1 ; er1 contains address plus two
  388. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  389. test_gr_a5a5 2
  390. test_gr_a5a5 3
  391. test_gr_a5a5 4
  392. test_gr_a5a5 5
  393. test_gr_a5a5 6
  394. test_gr_a5a5 7
  395. neg_w_rdpostdec:
  396. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  397. set_ccr_zero
  398. ;; neg.w @eRd-
  399. mov #word_dest, er1
  400. neg.w @er1-
  401. ;;; .word 0x0156
  402. ;;; .word 0x6d18
  403. ;;; .word 0x1790
  404. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  405. test_ovf_clear
  406. test_zero_clear
  407. test_neg_clear
  408. cmp.w #0x5a5b, @word_dest
  409. beq .Lwpostdec
  410. fail
  411. .Lwpostdec:
  412. test_h_gr32 word_dest-2 er1 ; er1 contains address minus two
  413. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  414. test_gr_a5a5 2
  415. test_gr_a5a5 3
  416. test_gr_a5a5 4
  417. test_gr_a5a5 5
  418. test_gr_a5a5 6
  419. test_gr_a5a5 7
  420. neg_w_rdpreinc:
  421. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  422. set_ccr_zero
  423. ;; neg.w @+eRd
  424. mov #word_dest-2, er1
  425. neg.w @+er1 ; reg pre-increment operand
  426. ;;; .word 0x0155
  427. ;;; .word 0x6d18
  428. ;;; .word 0x1790
  429. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  430. test_ovf_clear
  431. test_zero_clear
  432. test_neg_set
  433. cmp.w #0xa5a5, @word_dest
  434. beq .Lwpreinc
  435. fail
  436. .Lwpreinc:
  437. test_h_gr32 word_dest er1 ; er1 contains destination address
  438. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  439. test_gr_a5a5 2
  440. test_gr_a5a5 3
  441. test_gr_a5a5 4
  442. test_gr_a5a5 5
  443. test_gr_a5a5 6
  444. test_gr_a5a5 7
  445. neg_w_rdpredec:
  446. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  447. set_ccr_zero
  448. ;; neg.w @-eRd
  449. mov #word_dest+2, er1
  450. neg.w @-er1 ; reg pre-decr operand
  451. ;;; .word 0x0157
  452. ;;; .word 0x6d18
  453. ;;; .word 0x1790
  454. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  455. test_ovf_clear
  456. test_zero_clear
  457. test_neg_clear
  458. cmp.w #0x5a5b, @word_dest
  459. beq .Lwpredec
  460. fail
  461. .Lwpredec:
  462. test_h_gr32 word_dest er1 ; er1 contains destination address
  463. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  464. test_gr_a5a5 2
  465. test_gr_a5a5 3
  466. test_gr_a5a5 4
  467. test_gr_a5a5 5
  468. test_gr_a5a5 6
  469. test_gr_a5a5 7
  470. neg_w_disp2dst:
  471. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  472. set_ccr_zero
  473. ;; neg.w @(dd:2, erd)
  474. mov #word_dest-2, er1
  475. neg.w @(2:2, er1) ; reg plus 2-bit displacement
  476. ;;; .word 0x0155
  477. ;;; .word 0x6918
  478. ;;; .word 0x1790
  479. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  480. test_ovf_clear
  481. test_zero_clear
  482. test_neg_set
  483. cmp.w #0xa5a5, @word_dest
  484. beq .Lwdisp2
  485. fail
  486. .Lwdisp2:
  487. test_h_gr32 word_dest-2 er1 ; er1 contains address minus one
  488. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  489. test_gr_a5a5 2
  490. test_gr_a5a5 3
  491. test_gr_a5a5 4
  492. test_gr_a5a5 5
  493. test_gr_a5a5 6
  494. test_gr_a5a5 7
  495. neg_w_disp16dst:
  496. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  497. set_ccr_zero
  498. ;; neg.w @(dd:16, erd)
  499. mov #word_dest+100, er1
  500. neg.w @(-100:16, er1) ; reg plus 16-bit displacement
  501. ;;; .word 0x0154
  502. ;;; .word 0x6f18
  503. ;;; .word -100
  504. ;;; .word 0x1790
  505. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  506. test_ovf_clear
  507. test_zero_clear
  508. test_neg_clear
  509. cmp.w #0x5a5b, @word_dest
  510. beq .Lwdisp16
  511. fail
  512. .Lwdisp16:
  513. test_h_gr32 word_dest+100 er1 ; er1 contains destination address
  514. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  515. test_gr_a5a5 2
  516. test_gr_a5a5 3
  517. test_gr_a5a5 4
  518. test_gr_a5a5 5
  519. test_gr_a5a5 6
  520. test_gr_a5a5 7
  521. neg_w_disp32dst:
  522. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  523. set_ccr_zero
  524. ;; neg.w @(dd:32, erd)
  525. mov #word_dest-0xfffff, er1
  526. neg.w @(0xfffff:32, er1) ; reg plus 32-bit displacement
  527. ;;; .word 0x7814
  528. ;;; .word 0x6b28
  529. ;;; .long 0xfffff
  530. ;;; .word 0x1790
  531. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  532. test_ovf_clear
  533. test_zero_clear
  534. test_neg_set
  535. cmp.w #0xa5a5, @word_dest
  536. beq .Lwdisp32
  537. fail
  538. .Lwdisp32:
  539. test_h_gr32 word_dest-0xfffff er1 ; er1 contains destination address
  540. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  541. test_gr_a5a5 2
  542. test_gr_a5a5 3
  543. test_gr_a5a5 4
  544. test_gr_a5a5 5
  545. test_gr_a5a5 6
  546. test_gr_a5a5 7
  547. neg_w_abs16dst:
  548. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  549. set_ccr_zero
  550. ;; neg.w @aa:16
  551. neg.w @word_dest:16 ; 16-bit absolute address
  552. ;;; .word 0x6b18
  553. ;;; .word word_dest
  554. ;;; .word 0x1790
  555. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  556. test_ovf_clear
  557. test_zero_clear
  558. test_neg_clear
  559. cmp.w #0x5a5b, @word_dest
  560. beq .Lwabs16
  561. fail
  562. .Lwabs16:
  563. test_gr_a5a5 0 ; Make sure ALL general regs not disturbed
  564. test_gr_a5a5 1
  565. test_gr_a5a5 2
  566. test_gr_a5a5 3
  567. test_gr_a5a5 4
  568. test_gr_a5a5 5
  569. test_gr_a5a5 6
  570. test_gr_a5a5 7
  571. neg_w_abs32dst:
  572. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  573. set_ccr_zero
  574. ;; neg.w @aa:32
  575. neg.w @word_dest:32 ; 32-bit absolute address
  576. ;;; .word 0x6b38
  577. ;;; .long word_dest
  578. ;;; .word 0x1790
  579. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  580. test_ovf_clear
  581. test_zero_clear
  582. test_neg_set
  583. cmp.w #0xa5a5, @word_dest
  584. beq .Lwabs32
  585. fail
  586. .Lwabs32:
  587. test_gr_a5a5 0 ; Make sure ALL general regs not disturbed
  588. test_gr_a5a5 1
  589. test_gr_a5a5 2
  590. test_gr_a5a5 3
  591. test_gr_a5a5 4
  592. test_gr_a5a5 5
  593. test_gr_a5a5 6
  594. test_gr_a5a5 7
  595. .endif ; h8sx
  596. .endif ; h8/300
  597. #
  598. # 32-bit word operations
  599. #
  600. .if (sim_cpu) ; any except plain-vanilla h8/300
  601. neg_l_reg16:
  602. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  603. set_ccr_zero
  604. ;; neg.l eRd
  605. neg er1 ; 32-bit register operand
  606. ;;; .word 0x17b1
  607. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  608. test_ovf_clear
  609. test_zero_clear
  610. test_neg_clear
  611. cmp.l #0x5a5a5a5b, er1 ; result of "neg 0xa5a5a5a5"
  612. beq .Llrd
  613. fail
  614. .Llrd:
  615. test_h_gr32 0x5a5a5a5b er1 ; er1 changed by 'neg'
  616. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  617. test_gr_a5a5 2
  618. test_gr_a5a5 3
  619. test_gr_a5a5 4
  620. test_gr_a5a5 5
  621. test_gr_a5a5 6
  622. test_gr_a5a5 7
  623. .if (sim_cpu == h8sx)
  624. neg_l_rdind:
  625. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  626. set_ccr_zero
  627. ;; neg.l @eRd
  628. mov #long_dest, er1
  629. neg.l @er1 ; register indirect operand
  630. ;;; .word 0x0104
  631. ;;; .word 0x6d18
  632. ;;; .word 0x17b0
  633. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  634. test_ovf_clear
  635. test_zero_clear
  636. test_neg_clear
  637. cmp.l #0x5a5a5a5b, @long_dest ; memory contents changed
  638. beq .Llind
  639. fail
  640. .Llind:
  641. test_h_gr32 long_dest er1 ; er1 still contains address
  642. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  643. test_gr_a5a5 2
  644. test_gr_a5a5 3
  645. test_gr_a5a5 4
  646. test_gr_a5a5 5
  647. test_gr_a5a5 6
  648. test_gr_a5a5 7
  649. neg_l_rdpostinc:
  650. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  651. set_ccr_zero
  652. ;; neg.l @eRd+
  653. mov #long_dest, er1 ; register post-increment operand
  654. neg.l @er1+
  655. ;;; .word 0x0104
  656. ;;; .word 0x6d18
  657. ;;; .word 0x17b0
  658. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  659. test_ovf_clear
  660. test_zero_clear
  661. test_neg_set
  662. cmp.l #0xa5a5a5a5, @long_dest
  663. beq .Llpostinc
  664. fail
  665. .Llpostinc:
  666. test_h_gr32 long_dest+4 er1 ; er1 contains address plus two
  667. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  668. test_gr_a5a5 2
  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. neg_l_rdpostdec:
  675. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  676. set_ccr_zero
  677. ;; neg.l @eRd-
  678. mov #long_dest, er1
  679. neg.l @er1-
  680. ;;; .word 0x0106
  681. ;;; .word 0x6d18
  682. ;;; .word 0x17b0
  683. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  684. test_ovf_clear
  685. test_zero_clear
  686. test_neg_clear
  687. cmp.l #0x5a5a5a5b, @long_dest
  688. beq .Llpostdec
  689. fail
  690. .Llpostdec:
  691. test_h_gr32 long_dest-4 er1 ; er1 contains address minus two
  692. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  693. test_gr_a5a5 2
  694. test_gr_a5a5 3
  695. test_gr_a5a5 4
  696. test_gr_a5a5 5
  697. test_gr_a5a5 6
  698. test_gr_a5a5 7
  699. neg_l_rdpreinc:
  700. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  701. set_ccr_zero
  702. ;; neg.l @+eRd
  703. mov #long_dest-4, er1
  704. neg.l @+er1 ; reg pre-increment operand
  705. ;;; .word 0x0105
  706. ;;; .word 0x6d18
  707. ;;; .word 0x17b0
  708. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  709. test_ovf_clear
  710. test_zero_clear
  711. test_neg_set
  712. cmp.l #0xa5a5a5a5, @long_dest
  713. beq .Llpreinc
  714. fail
  715. .Llpreinc:
  716. test_h_gr32 long_dest er1 ; er1 contains destination address
  717. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  718. test_gr_a5a5 2
  719. test_gr_a5a5 3
  720. test_gr_a5a5 4
  721. test_gr_a5a5 5
  722. test_gr_a5a5 6
  723. test_gr_a5a5 7
  724. neg_l_rdpredec:
  725. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  726. set_ccr_zero
  727. ;; neg.l @-eRd
  728. mov #long_dest+4, er1
  729. neg.l @-er1 ; reg pre-decr operand
  730. ;;; .word 0x0107
  731. ;;; .word 0x6d18
  732. ;;; .word 0x17b0
  733. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  734. test_ovf_clear
  735. test_zero_clear
  736. test_neg_clear
  737. cmp.l #0x5a5a5a5b, @long_dest
  738. beq .Llpredec
  739. fail
  740. .Llpredec:
  741. test_h_gr32 long_dest er1 ; er1 contains destination address
  742. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  743. test_gr_a5a5 2
  744. test_gr_a5a5 3
  745. test_gr_a5a5 4
  746. test_gr_a5a5 5
  747. test_gr_a5a5 6
  748. test_gr_a5a5 7
  749. neg_l_disp2dst:
  750. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  751. set_ccr_zero
  752. ;; neg.l @(dd:2, erd)
  753. mov #long_dest-4, er1
  754. neg.l @(4:2, er1) ; reg plus 2-bit displacement
  755. ;;; .word 0x0105
  756. ;;; .word 0x6918
  757. ;;; .word 0x17b0
  758. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  759. test_ovf_clear
  760. test_zero_clear
  761. test_neg_set
  762. cmp.l #0xa5a5a5a5, @long_dest
  763. beq .Lldisp2
  764. fail
  765. .Lldisp2:
  766. test_h_gr32 long_dest-4 er1 ; er1 contains address minus one
  767. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  768. test_gr_a5a5 2
  769. test_gr_a5a5 3
  770. test_gr_a5a5 4
  771. test_gr_a5a5 5
  772. test_gr_a5a5 6
  773. test_gr_a5a5 7
  774. neg_l_disp16dst:
  775. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  776. set_ccr_zero
  777. ;; neg.l @(dd:16, erd)
  778. mov #long_dest+100, er1
  779. neg.l @(-100:16, er1) ; reg plus 16-bit displacement
  780. ;;; .word 0x0104
  781. ;;; .word 0x6f18
  782. ;;; .word -100
  783. ;;; .word 0x17b0
  784. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  785. test_ovf_clear
  786. test_zero_clear
  787. test_neg_clear
  788. cmp.l #0x5a5a5a5b, @long_dest
  789. beq .Lldisp16
  790. fail
  791. .Lldisp16:
  792. test_h_gr32 long_dest+100 er1 ; er1 contains destination address
  793. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  794. test_gr_a5a5 2
  795. test_gr_a5a5 3
  796. test_gr_a5a5 4
  797. test_gr_a5a5 5
  798. test_gr_a5a5 6
  799. test_gr_a5a5 7
  800. neg_l_disp32dst:
  801. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  802. set_ccr_zero
  803. ;; neg.l @(dd:32, erd)
  804. mov #long_dest-0xfffff, er1
  805. neg.l @(0xfffff:32, er1) ; reg plus 32-bit displacement
  806. ;;; .word 0x7894
  807. ;;; .word 0x6b28
  808. ;;; .long 0xfffff
  809. ;;; .word 0x17b0
  810. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  811. test_ovf_clear
  812. test_zero_clear
  813. test_neg_set
  814. cmp.l #0xa5a5a5a5, @long_dest
  815. beq .Lldisp32
  816. fail
  817. .Lldisp32:
  818. test_h_gr32 long_dest-0xfffff er1 ; er1 contains destination address
  819. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  820. test_gr_a5a5 2
  821. test_gr_a5a5 3
  822. test_gr_a5a5 4
  823. test_gr_a5a5 5
  824. test_gr_a5a5 6
  825. test_gr_a5a5 7
  826. neg_l_abs16dst:
  827. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  828. set_ccr_zero
  829. ;; neg.l @aa:16
  830. neg.l @long_dest:16 ; 16-bit absolute address
  831. ;;; .word 0x0104
  832. ;;; .word 0x6b08
  833. ;;; .word long_dest
  834. ;;; .word 0x17b0
  835. test_carry_set ; H=0 N=0 Z=0 V=0 C=1
  836. test_ovf_clear
  837. test_zero_clear
  838. test_neg_clear
  839. cmp.l #0x5a5a5a5b, @long_dest
  840. beq .Llabs16
  841. fail
  842. .Llabs16:
  843. test_gr_a5a5 0 ; Make sure ALL general regs not disturbed
  844. test_gr_a5a5 1
  845. test_gr_a5a5 2
  846. test_gr_a5a5 3
  847. test_gr_a5a5 4
  848. test_gr_a5a5 5
  849. test_gr_a5a5 6
  850. test_gr_a5a5 7
  851. neg_l_abs32dst:
  852. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  853. set_ccr_zero
  854. ;; neg.l @aa:32
  855. neg.l @long_dest:32 ; 32-bit absolute address
  856. ;;; .word 0x0104
  857. ;;; .word 0x6b28
  858. ;;; .long long_dest
  859. ;;; .word 0x17b0
  860. test_carry_set ; H=0 N=1 Z=0 V=0 C=1
  861. test_ovf_clear
  862. test_zero_clear
  863. test_neg_set
  864. cmp.l #0xa5a5a5a5, @long_dest
  865. beq .Llabs32
  866. fail
  867. .Llabs32:
  868. test_gr_a5a5 0 ; Make sure ALL general regs not disturbed
  869. test_gr_a5a5 1
  870. test_gr_a5a5 2
  871. test_gr_a5a5 3
  872. test_gr_a5a5 4
  873. test_gr_a5a5 5
  874. test_gr_a5a5 6
  875. test_gr_a5a5 7
  876. .endif ; h8sx
  877. .endif ; h8/300
  878. pass
  879. exit 0