mfspr.S 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* Tests instructions l.mfspr and l.mtspr.
  2. Copyright (C) 2017-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(0x00000000);\n
  15. # output: report(0x00002801);\n
  16. # output: report(0xdeadbeef);\n
  17. # output: \n
  18. # output: report(0x00002801);\n
  19. # output: report(0x00000000);\n
  20. # output: report(0xdeadbeef);\n
  21. # output: \n
  22. # output: report(0x00002801);\n
  23. # output: report(0x00002801);\n
  24. # output: report(0xdeadbeef);\n
  25. # output: \n
  26. # output: report(0x00000801);\n
  27. # output: report(0x00002000);\n
  28. # output: report(0xdeadbeef);\n
  29. # output: \n
  30. # output: report(0x00002000);\n
  31. # output: report(0x00000801);\n
  32. # output: report(0xdeadbeef);\n
  33. # output: \n
  34. # output: report(0x00002801);\n
  35. # output: report(0x00000001);\n
  36. # output: report(0xdeadbeef);\n
  37. # output: \n
  38. # output: report(0x00000800);\n
  39. # output: report(0x00002801);\n
  40. # output: report(0xdeadbeef);\n
  41. # output: \n
  42. # output: report(0x00000000);\n
  43. # output: report(0x00002801);\n
  44. # output: report(0xdeadbeef);\n
  45. # output: \n
  46. # output: report(0x00002801);\n
  47. # output: report(0x00000000);\n
  48. # output: report(0xdeadbeef);\n
  49. # output: \n
  50. # output: report(0x00002801);\n
  51. # output: report(0x00002801);\n
  52. # output: report(0xdeadbeef);\n
  53. # output: \n
  54. # output: report(0x00000801);\n
  55. # output: report(0x00002000);\n
  56. # output: report(0xdeadbeef);\n
  57. # output: \n
  58. # output: report(0x00002000);\n
  59. # output: report(0x00000801);\n
  60. # output: report(0xdeadbeef);\n
  61. # output: \n
  62. # output: report(0x00002801);\n
  63. # output: report(0x00000001);\n
  64. # output: report(0xdeadbeef);\n
  65. # output: \n
  66. # output: report(0x00000800);\n
  67. # output: report(0x00002801);\n
  68. # output: report(0xdeadbeef);\n
  69. # output: \n
  70. # output: exit(0)\n
  71. #include "or1k-asm-test-env.h"
  72. #define MACLO_VAL 0xdeadbeef
  73. /* A macro to carry out a test of l.mfspr.
  74. MACLO (0x2801) is used as the SPR, since it can be read and
  75. cleared using l.macrc and can be set using l.maci. spr_number
  76. and immediate_val_to_or should be chosen to address this
  77. register.
  78. The value placed in the register is entirely arbitrary - we use
  79. 0xdeadbeef. */
  80. .macro TEST_MFSPR spr_number, immediate_val_to_or
  81. REPORT_IMMEDIATE_TO_CONSOLE \spr_number
  82. REPORT_IMMEDIATE_TO_CONSOLE \immediate_val_to_or
  83. /* Write MACLO_VAL to MACLO. */
  84. l.macrc r2
  85. LOAD_IMMEDIATE r2, MACLO_VAL
  86. l.maci r2, 1
  87. LOAD_IMMEDIATE r5, \spr_number
  88. l.mfspr r4, r5, \immediate_val_to_or
  89. REPORT_REG_TO_CONSOLE r4
  90. PRINT_NEWLINE_TO_CONSOLE
  91. .endm
  92. /* A macro to carry out a test of l.mtspr
  93. MACLO (0x2801) is used as the SPR, since it can be read and
  94. cleared using l.macrc and can be set using l.maci. The
  95. arguments spr_number and immediate_val_to_or should be chosen
  96. to address this register.
  97. The value placed in the register is entirely arbitrary - we use
  98. 0xdeadbeef. */
  99. .macro TEST_MTSPR spr_number, immediate_val_to_or
  100. REPORT_IMMEDIATE_TO_CONSOLE \spr_number
  101. REPORT_IMMEDIATE_TO_CONSOLE \immediate_val_to_or
  102. /* Clear MACLO */
  103. l.macrc r2
  104. LOAD_IMMEDIATE r4, MACLO_VAL
  105. LOAD_IMMEDIATE r5, \spr_number
  106. l.mtspr r5, r4, \immediate_val_to_or
  107. /* Retrieve MACLO. */
  108. l.macrc r4
  109. REPORT_REG_TO_CONSOLE r4
  110. PRINT_NEWLINE_TO_CONSOLE
  111. .endm
  112. STANDARD_TEST_ENVIRONMENT
  113. .section .text
  114. start_tests:
  115. PUSH LINK_REGISTER_R9
  116. /* Test the l.mfspr instruction with a range of operands. */
  117. /* Move a test value using zero in the register. */
  118. TEST_MFSPR SPR_VR, SPR_MACLO /* 0x0000, 0x2801 */
  119. /* Move a test value using zero as the constant. */
  120. TEST_MFSPR SPR_MACLO, SPR_VR /* 0x2801, 0x0000 */
  121. /* Move a test value using non-zero in both register and constant. */
  122. /* Some of these values will not give the correct result if OR
  123. rather than ADD is used to determine the SPR address. */
  124. TEST_MFSPR SPR_MACLO, SPR_MACLO /* 0x2801, 0x2801 */
  125. TEST_MFSPR SPR_DMMUPR, SPR_ICCR /* 0x0801, 0x2000 */
  126. TEST_MFSPR SPR_ICCR, SPR_DMMUPR /* 0x2000, 0x0801 */
  127. TEST_MFSPR SPR_MACLO, SPR_UPR /* 0x2801, 0x0001 */
  128. TEST_MFSPR SPR_DMMUCR, SPR_MACLO /* 0x0800, 0x2801 */
  129. /* Test the l.mtspr instruction with a range of operands. */
  130. /* Move a test value using zero in the register. */
  131. TEST_MTSPR SPR_VR, SPR_MACLO /* 0x0000, 0x2801 */
  132. /* Move a test value using zero as the constant. */
  133. TEST_MTSPR SPR_MACLO, SPR_VR /* 0x2801, 0x0000 */
  134. /* Move a test value using non-zero in both register and constant. */
  135. /* Some of these values will not give the correct result if or
  136. rather than add is used to determine the SPR address. */
  137. TEST_MTSPR SPR_MACLO, SPR_MACLO /* 0x2801, 0x2801 */
  138. TEST_MTSPR SPR_DMMUPR, SPR_ICCR /* 0x0801, 0x2000 */
  139. TEST_MTSPR SPR_ICCR, SPR_DMMUPR /* 0x2000, 0x0801 */
  140. TEST_MTSPR SPR_MACLO, SPR_UPR /* 0x2801, 0x0001 */
  141. TEST_MTSPR SPR_DMMUCR, SPR_MACLO /* 0x0800, 0x2801 */
  142. POP LINK_REGISTER_R9
  143. RETURN_TO_LINK_REGISTER_R9