adrp.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Tests the load page address instruction.
  2. Copyright (C) 2019-2022 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. # mach: or1k
  14. # output: report(0x00002064);\n
  15. # output: report(0x00012138);\n
  16. # output: report(0x00002000);\n
  17. # output: report(0x00012000);\n
  18. # output: report(0x00002000);\n
  19. # output: report(0x00014000);\n
  20. # output: report(0x00000000);\n
  21. # output: exit(0)\n
  22. #include "or1k-asm-test-helpers.h"
  23. STANDARD_TEST_ENVIRONMENT
  24. .section .data
  25. .org 0x10000
  26. .align 4
  27. .type pi, @object
  28. .size pi, 4
  29. pi:
  30. .float 3.14159
  31. .section .text
  32. start_tests:
  33. PUSH LINK_REGISTER_R9
  34. /* Print out the PC. To compare with that loaded by l.adrp. */
  35. l.jal capture_pc
  36. l.nop
  37. capture_pc:
  38. REPORT_REG_TO_CONSOLE r9
  39. /* Print out our data address to compared with l.adrp offset. */
  40. l.movhi r11, ha(pi)
  41. l.addi r11, r11, lo(pi)
  42. REPORT_REG_TO_CONSOLE r11
  43. /* Test l.adrp with symbols, loads page of symbol to register. */
  44. l.adrp r4, start_tests
  45. REPORT_REG_TO_CONSOLE r4
  46. l.adrp r4, pi
  47. REPORT_REG_TO_CONSOLE r4
  48. /* Test l.adrp with immediate, immediate is the page offset. */
  49. l.adrp r4, 0x0
  50. REPORT_REG_TO_CONSOLE r4
  51. l.adrp r4, 0x12000
  52. REPORT_REG_TO_CONSOLE r4
  53. l.adrp r4, -0x2000
  54. REPORT_REG_TO_CONSOLE r4
  55. POP LINK_REGISTER_R9
  56. RETURN_TO_LINK_REGISTER_R9