bra.s 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. # Hitachi H8 testcase 'bra'
  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. start
  12. .if (sim_cpu == h8sx)
  13. .data
  14. .align 4
  15. disp8: .long tgt_reg8
  16. disp16: .long tgt_reg16
  17. disp32: .long tgt_reg32
  18. dslot: .byte 0
  19. .text
  20. .endif
  21. bra_8:
  22. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  23. set_ccr_zero
  24. ;; bra dd:8 ; 8-bit displacement
  25. bra tgt_8:8
  26. ;;; .word 0x40xx ; where "xx" is tgt_8 - '.'.
  27. fail
  28. tgt_8:
  29. test_cc_clear
  30. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  31. test_gr_a5a5 1
  32. test_gr_a5a5 2
  33. test_gr_a5a5 3
  34. test_gr_a5a5 4
  35. test_gr_a5a5 5
  36. test_gr_a5a5 6
  37. test_gr_a5a5 7
  38. .if (sim_cpu) ; not available in h8/300 mode
  39. bra_16:
  40. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  41. set_ccr_zero
  42. ;; bra dd:16 ; 16-bit displacement
  43. bra tgt_24:16 ; NOTE: hard-coded to avoid relaxing.
  44. ;;; .word 0x5800
  45. ;;; .word tgt_24 - .
  46. fail
  47. tgt_24:
  48. test_cc_clear
  49. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  50. test_gr_a5a5 1
  51. test_gr_a5a5 2
  52. test_gr_a5a5 3
  53. test_gr_a5a5 4
  54. test_gr_a5a5 5
  55. test_gr_a5a5 6
  56. test_gr_a5a5 7
  57. .endif
  58. .if (sim_cpu == h8sx)
  59. bra_reg8:
  60. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  61. set_ccr_zero
  62. ;; bra rn.b ; 8-bit register indirect
  63. sub.l #src8, @disp8
  64. mov.l @disp8, er5
  65. bra r5l.b
  66. ;;; .word 0x5955
  67. src8: fail
  68. tgt_reg8:
  69. test_cc_clear
  70. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  71. test_gr_a5a5 1
  72. test_gr_a5a5 2
  73. test_gr_a5a5 3
  74. test_gr_a5a5 4
  75. ;;; test_h_gr32 tgt_reg8 er5
  76. test_gr_a5a5 6
  77. test_gr_a5a5 7
  78. bra_reg16:
  79. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  80. set_ccr_zero
  81. ;; bra rn.w ; 16-bit register indirect
  82. sub.l #src16, @disp16
  83. mov.l @disp16, er5
  84. bra r5.w
  85. ;;; .word 0x5956
  86. src16: fail
  87. tgt_reg16:
  88. test_cc_clear
  89. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  90. test_gr_a5a5 1
  91. test_gr_a5a5 2
  92. test_gr_a5a5 3
  93. test_gr_a5a5 4
  94. ;;; test_h_gr32 tgt_reg16 er5
  95. test_gr_a5a5 6
  96. test_gr_a5a5 7
  97. bra_reg32:
  98. set_grs_a5a5 ; Fill all general regs with a fixed pattern
  99. set_ccr_zero
  100. ;; bra ern ; 32-bit register indirect
  101. sub.l #src32, @disp32
  102. mov.l @disp32, er5
  103. bra er5.l
  104. ;;; .word 0x5957
  105. src32: fail
  106. tgt_reg32:
  107. test_cc_clear
  108. test_gr_a5a5 0 ; Make sure other general regs not disturbed
  109. test_gr_a5a5 1
  110. test_gr_a5a5 2
  111. test_gr_a5a5 3
  112. test_gr_a5a5 4
  113. ;;; test_gr_a5a5 5
  114. test_gr_a5a5 6
  115. test_gr_a5a5 7
  116. bra_s: set_grs_a5a5
  117. set_ccr_zero
  118. bra/s tgt_post_delay
  119. ;;; .word 0x4017
  120. ;; The following instruction is in the delay slot, and should execute.
  121. mov.b #1, @dslot
  122. ;; After this, the next instructions should not execute.
  123. fail
  124. tgt_post_delay:
  125. test_cc_clear
  126. cmp.b #0, @dslot ; Should be non-zero if delay slot executed.
  127. bne dslot_ok
  128. fail
  129. dslot_ok:
  130. test_gr_a5a5 0 ; Make sure all general regs not disturbed
  131. test_gr_a5a5 1
  132. test_gr_a5a5 2
  133. test_gr_a5a5 3
  134. test_gr_a5a5 4
  135. test_gr_a5a5 5
  136. test_gr_a5a5 6
  137. test_gr_a5a5 7
  138. .endif
  139. pass
  140. exit 0