thumb_blx_in_range.s 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # thumb_blx_in_range.s
  2. #
  3. # Test THUMB/THUMB-2 blx instructions just within the branch range limits.
  4. # Because bit 1 of the branch target comes from the branch instruction
  5. # address, the branch range from PC (branch instruction address + 4) is
  6. # acutally -((1<<22) + 2) to ((1<<22) - 4) for THUMB and -((1<<24) + 2) to
  7. # ((1<<24) - 4) from THUMB2.
  8. .syntax unified
  9. .section .text.pre,"x"
  10. # Add padding so that target is just in branch range.
  11. .space 8
  12. .align 2
  13. .global _backward_target
  14. .code 32
  15. .type _backword_target, %function
  16. _backward_target:
  17. bx lr
  18. .size _backward_target, .-_backward_target
  19. .text
  20. # Define _start so that linker does not complain.
  21. .global _start
  22. .code 32
  23. .align 2
  24. .type _start, %function
  25. _start:
  26. bx lr
  27. .size _start, .-_start
  28. .global _backward_test
  29. .code 16
  30. .thumb_func
  31. .type _backward_test, %function
  32. _backward_test:
  33. nop.n
  34. blx _backward_target
  35. .size _backward_test, .-_backward_test
  36. .align 2
  37. .global _forward_test
  38. .code 16
  39. .thumb_func
  40. .type _forward_test, %function
  41. _forward_test:
  42. blx _forward_target
  43. .size _forward_test, .-_forward_test
  44. .code 32
  45. .section .text.post,"x"
  46. # Add padding so that target is just in branch range.
  47. .space 12
  48. .align 2
  49. .global _forward_target
  50. .code 32
  51. .type _forward_target, %function
  52. _forward_target:
  53. bx lr
  54. .size _forward_target, .-_forward_target