relax-group.s 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. ;;; Test 68HC11 linker relaxation (group relax)
  2. ;;;
  3. .sect .text
  4. .globl _start
  5. _start:
  6. ;;;
  7. ;;; The following group of instructions are adjusted.
  8. ;;;
  9. .relax L1x
  10. ldx #table
  11. bset 0,x #4
  12. L1x:
  13. .relax L1y
  14. ldy #table
  15. bset 0,y #4
  16. L1y:
  17. .relax L2x
  18. ldx #table+3
  19. bset 0,x #4
  20. bset 1,x #8
  21. L2x:
  22. .relax L2y
  23. ldy #table+3
  24. bset 0,y #4
  25. bset 1,y #8
  26. L2y:
  27. .relax L3x
  28. ldx #table+6
  29. bset 0,x #4
  30. bset 1,x #8
  31. bset 2,x #12
  32. bset 3,x #12
  33. bset 4,x #12
  34. bset 5,x #12
  35. L3x:
  36. .relax L3y
  37. ldy #table+6
  38. bset 0,y #4
  39. bset 1,y #8
  40. bset 2,y #12
  41. bset 3,y #12
  42. bset 4,y #12
  43. bset 5,y #12
  44. L3y:
  45. ;; Next branch is always relative. It must be adjusted while
  46. ;; above instructions are relaxed.
  47. bra _start
  48. ;;;
  49. ;;; This group has the first two bset insn relaxable while the
  50. ;;; others are not. The ldx/ldy must not be removed.
  51. ;;;
  52. .relax L4x
  53. ldx #table+0xfe
  54. bset 0,x #4
  55. bset 1,x #8
  56. bset 2,x #12
  57. bset 3,x #12
  58. bset 4,x #12
  59. bset 5,x #12
  60. L4x:
  61. .relax L4y
  62. ldy #table+0xfe
  63. bset 0,y #4
  64. bset 1,y #8
  65. bset 2,y #12
  66. bset 3,y #12
  67. bset 4,y #12
  68. bset 5,y #12
  69. L4y:
  70. ;;;
  71. ;;; Relax group for bclr
  72. ;;;
  73. .relax L5x
  74. ldx #table+10
  75. bclr 0,x #4
  76. bclr 1,x #8
  77. L5x:
  78. .relax L5y
  79. ldy #table+16
  80. bclr 10,y #4
  81. bclr 11,y #8
  82. L5y:
  83. ;;;
  84. ;;; Relax group for brset (with backward branch)
  85. ;;;
  86. .relax L6x
  87. ldx #table+8
  88. brset 0,x #4 L5y
  89. L6x:
  90. .relax L7x
  91. ldy #table+8
  92. brset 0,y #4 L6x
  93. L7x:
  94. ;;;
  95. ;;; Relax group for brset (with forward branch)
  96. ;;;
  97. .relax L8x
  98. ldx #table+8
  99. brset 0,x #4 brend
  100. L8x:
  101. .relax L8y
  102. ldy #table+8
  103. brset 0,y #4 brend
  104. L8y:
  105. ;;;
  106. ;;; Relax group for brclr (with backward branch)
  107. ;;;
  108. .relax L9x
  109. ldx #table+8
  110. brclr 0,x #4 L8y
  111. L9x:
  112. .relax L9y
  113. ldy #table+8
  114. brclr 0,y #4 L9x
  115. L9y:
  116. ;;;
  117. ;;; Relax group for brclr (with forward branch)
  118. ;;;
  119. .relax L10x
  120. ldx #table+8
  121. brclr 0,x #4 brend
  122. L10x:
  123. .relax L10y
  124. ldy #table+8
  125. brclr 0,y #4 brend
  126. L10y:
  127. nop
  128. brend:
  129. ;;;
  130. ;;; The following are wrong use of .relax groups.
  131. ;;;
  132. .relax w1
  133. w1:
  134. .relax w2
  135. bset 0,x #4
  136. w2:
  137. .relax w3
  138. ldx #table
  139. w3:
  140. .relax w4
  141. ldy #table+8
  142. w4:
  143. .relax w5
  144. rts
  145. w5:
  146. ;;;
  147. ;;; Next insn is not in a .relax group
  148. ldx #table
  149. bset 0,x #5
  150. bra _start
  151. rts
  152. .sect .page0
  153. .globl table
  154. table: .long 0
  155. table4: .long 0
  156. table8: .long 0
  157. .skip 10
  158. end_table:
  159. .long 0