subb.s 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. # Hitachi H8 testcase 'sub.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. # sub.b #xx:8, rd ; <illegal>
  13. # sub.b #xx:8, @erd ; 7 d rd ???? a ???? xxxxxxxx
  14. # sub.b #xx:8, @erd+ ; 0 1 7 4 6 c rd 1??? a ???? xxxxxxxx
  15. # sub.b #xx:8, @erd- ; 0 1 7 6 6 c rd 1??? a ???? xxxxxxxx
  16. # sub.b rs, rd ; 1 8 rs rd
  17. # sub.b reg8, @erd ; 7 d rd ???? 1 8 rs ????
  18. # sub.b reg8, @erd+ ; 0 1 7 9 8 rd 3 rs
  19. # sub.b reg8, @erd- ; 0 1 7 9 a rd 3 rs
  20. #
  21. # Coming soon:
  22. # sub.b #xx:8, @+erd ; 0 1 7 5 6 c rd 1??? a ???? xxxxxxxx
  23. # sub.b #xx:8, @-erd ; 0 1 7 7 6 c rd 1??? a ???? xxxxxxxx
  24. # sub.b reg8, @+erd ; 0 1 7 9 9 rd 3 rs
  25. # sub.b reg8, @-erd ; 0 1 7 9 b rd 3 rs
  26. # ...
  27. .data
  28. pre_byte: .byte 0
  29. byte_dest: .byte 0xa5
  30. post_byte: .byte 0
  31. start
  32. .if (0) ; Guess what? Sub.b immediate reg8 is illegal!
  33. sub_b_imm8_reg:
  34. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  35. ;; fixme set ccr
  36. ;; sub.b #xx:8,Rd
  37. sub.b #5, r0l ; Immediate 8-bit operand
  38. ;; fixme test ccr ; H=0 N=1 Z=0 V=0 C=0
  39. test_h_gr16 0xa5a0 r0 ; sub result: a5 - 5
  40. .if (sim_cpu) ; non-zero means h8300h, s, or sx
  41. test_h_gr32 0xa5a5a5a0 er0 ; sub result: a5 - 5
  42. .endif
  43. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  44. test_gr_a5a5 2
  45. test_gr_a5a5 3
  46. test_gr_a5a5 4
  47. test_gr_a5a5 5
  48. test_gr_a5a5 6
  49. test_gr_a5a5 7
  50. .endif
  51. .if (sim_cpu == h8sx)
  52. sub_b_imm8_rdind:
  53. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  54. set_ccr_zero
  55. ;; sub.b #xx:8,@eRd
  56. mov #byte_dest, er0
  57. sub.b #5:8, @er0 ; Immediate 8-bit src, reg indirect dst
  58. ;;; .word 0x7d00
  59. ;;; .word 0xa105
  60. test_carry_clear ; H=0 N=1 Z=0 V=0 C=0
  61. test_ovf_clear
  62. test_zero_clear
  63. test_neg_set
  64. test_h_gr32 byte_dest, er0 ; er0 still contains address
  65. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  66. test_gr_a5a5 2
  67. test_gr_a5a5 3
  68. test_gr_a5a5 4
  69. test_gr_a5a5 5
  70. test_gr_a5a5 6
  71. test_gr_a5a5 7
  72. ;; Now check the result of the sub to memory.
  73. sub.b r0l, r0l
  74. mov.b @byte_dest, r0l
  75. cmp.b #0xa0, r0l
  76. beq .L1
  77. fail
  78. .L1:
  79. sub_b_imm8_rdpostinc:
  80. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  81. set_ccr_zero
  82. ;; sub.b #xx:8,@eRd+
  83. mov #byte_dest, er0
  84. sub.b #5:8, @er0+ ; Immediate 8-bit src, reg post-incr dest
  85. ;;; .word 0x0174
  86. ;;; .word 0x6c08
  87. ;;; .word 0xa105
  88. test_carry_clear ; H=0 N=1 Z=0 V=0 C=0
  89. test_ovf_clear
  90. test_zero_clear
  91. test_neg_set
  92. test_h_gr32 post_byte, er0 ; er0 still contains address plus one
  93. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  94. test_gr_a5a5 2
  95. test_gr_a5a5 3
  96. test_gr_a5a5 4
  97. test_gr_a5a5 5
  98. test_gr_a5a5 6
  99. test_gr_a5a5 7
  100. ;; Now check the result of the sub to memory.
  101. sub.b r0l, r0l
  102. mov.b @byte_dest, r0l
  103. cmp.b #0x9b, r0l
  104. beq .L2
  105. fail
  106. .L2:
  107. sub_b_imm8_rdpostdec:
  108. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  109. set_ccr_zero
  110. ;; sub.b #xx:8,@eRd-
  111. mov #byte_dest, er0
  112. sub.b #5:8, @er0- ; Immediate 8-bit src, reg post-decr dest
  113. ;;; .word 0x0176
  114. ;;; .word 0x6c08
  115. ;;; .word 0xa105
  116. test_carry_clear ; H=0 N=1 Z=0 V=0 C=0
  117. test_ovf_clear
  118. test_zero_clear
  119. test_neg_set
  120. test_h_gr32 pre_byte, er0 ; er0 still contains address minus one
  121. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  122. test_gr_a5a5 2
  123. test_gr_a5a5 3
  124. test_gr_a5a5 4
  125. test_gr_a5a5 5
  126. test_gr_a5a5 6
  127. test_gr_a5a5 7
  128. ;; Now check the result of the sub to memory.
  129. sub.b r0l, r0l
  130. mov.b @byte_dest, r0l
  131. cmp.b #0x96, r0l
  132. beq .L3
  133. fail
  134. .L3:
  135. .endif
  136. sub_b_reg8_reg8:
  137. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  138. ;; fixme set ccr
  139. ;; sub.b Rs,Rd
  140. mov.b #5, r0h
  141. sub.b r0h, r0l ; Register operand
  142. ;; fixme test ccr ; H=0 N=1 Z=0 V=0 C=0
  143. test_h_gr16 0x05a0 r0 ; sub result: a5 - 5
  144. .if (sim_cpu) ; non-zero means h8300h, s, or sx
  145. test_h_gr32 0xa5a505a0 er0 ; sub result: a5 - 5
  146. .endif
  147. test_gr_a5a5 1 ; Make sure other general regs not disturbed
  148. test_gr_a5a5 2
  149. test_gr_a5a5 3
  150. test_gr_a5a5 4
  151. test_gr_a5a5 5
  152. test_gr_a5a5 6
  153. test_gr_a5a5 7
  154. .if (sim_cpu == h8sx)
  155. sub_b_reg8_rdind:
  156. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  157. set_ccr_zero
  158. ;; sub.b rs8,@eRd ; Subx to register indirect
  159. mov #byte_dest, er0
  160. mov #5, r1l
  161. sub.b r1l, @er0 ; reg8 src, reg indirect dest
  162. ;;; .word 0x7d00
  163. ;;; .word 0x1890
  164. test_carry_clear ; H=0 N=1 Z=0 V=0 C=0
  165. test_ovf_clear
  166. test_zero_clear
  167. test_neg_set
  168. test_h_gr32 byte_dest er0 ; er0 still contains address
  169. test_h_gr32 0xa5a5a505 er1 ; er1 has the test load
  170. test_gr_a5a5 2 ; Make sure other general regs not disturbed
  171. test_gr_a5a5 3
  172. test_gr_a5a5 4
  173. test_gr_a5a5 5
  174. test_gr_a5a5 6
  175. test_gr_a5a5 7
  176. ;; Now check the result of the sub to memory.
  177. sub.b r0l, r0l
  178. mov.b @byte_dest, r0l
  179. cmp.b #0x91, r0l
  180. beq .L4
  181. fail
  182. .L4:
  183. sub_b_reg8_rdpostinc:
  184. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  185. set_ccr_zero
  186. ;; sub.b rs8,@eRd+ ; Subx to register indirect
  187. mov #byte_dest, er0
  188. mov #5, r1l
  189. sub.b r1l, @er0+ ; reg8 src, reg indirect dest
  190. ;;; .word 0x0179
  191. ;;; .word 0x8039
  192. test_carry_clear ; H=0 N=1 Z=0 V=0 C=0
  193. test_ovf_clear
  194. test_zero_clear
  195. test_neg_set
  196. test_h_gr32 post_byte er0 ; er0 still contains address plus one
  197. test_h_gr32 0xa5a5a505 er1 ; er1 has the test load
  198. test_gr_a5a5 2 ; Make sure other general regs not disturbed
  199. test_gr_a5a5 3
  200. test_gr_a5a5 4
  201. test_gr_a5a5 5
  202. test_gr_a5a5 6
  203. test_gr_a5a5 7
  204. ;; Now check the result of the sub to memory.
  205. sub.b r0l, r0l
  206. mov.b @byte_dest, r0l
  207. cmp.b #0x8c, r0l
  208. beq .L5
  209. fail
  210. .L5:
  211. ;; special case same register
  212. mov.l #byte_dest, er0
  213. mov.b @er0, r1h
  214. mov.b r1h, r2l
  215. mov.b r0l, r1l
  216. sub.b r0l, @er0+
  217. inc.b r1l
  218. sub.b r1l, r1h
  219. mov.b @byte_dest, r0l
  220. cmp.b r1h, r0l
  221. beq .L25
  222. fail
  223. .L25:
  224. mov.b r2l, @byte_dest
  225. sub_b_reg8_rdpostdec:
  226. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  227. set_ccr_zero
  228. ;; sub.b rs8,@eRd- ; Subx to register indirect
  229. mov #byte_dest, er0
  230. mov #5, r1l
  231. sub.b r1l, @er0- ; reg8 src, reg indirect dest
  232. ;;; .word 0x0179
  233. ;;; .word 0xa039
  234. test_carry_clear ; H=0 N=1 Z=0 V=0 C=0
  235. test_ovf_clear
  236. test_zero_clear
  237. test_neg_set
  238. test_h_gr32 pre_byte er0 ; er0 still contains address minus one
  239. test_h_gr32 0xa5a5a505 er1 ; er1 has the test load
  240. test_gr_a5a5 2 ; Make sure other general regs not disturbed
  241. test_gr_a5a5 3
  242. test_gr_a5a5 4
  243. test_gr_a5a5 5
  244. test_gr_a5a5 6
  245. test_gr_a5a5 7
  246. ;; Now check the result of the sub to memory.
  247. sub.b r0l, r0l
  248. mov.b @byte_dest, r0l
  249. cmp.b #0x87, r0l
  250. beq .L6
  251. fail
  252. .L6:
  253. ;; special case same register
  254. mov.l #byte_dest, er0
  255. mov.b @er0, r1h
  256. mov.b r0l, r1l
  257. sub.b r0l, @er0-
  258. dec.b r1l
  259. sub.b r1l, r1h
  260. mov.b @byte_dest, r0l
  261. cmp.b r1h, r0l
  262. beq .L26
  263. fail
  264. .L26:
  265. .endif
  266. pass
  267. exit 0