1 /* Tests instructions l.ror and l.rori. 2 3 Copyright (C) 2017-2024 Free Software Foundation, Inc. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 18 # mach: or1k 19 # output: report(0xb38f0f83);\n 20 # output: report(0x00000000);\n 21 # output: report(0xb38f0f83);\n 22 # output: \n 23 # output: report(0xb38f0f83);\n 24 # output: report(0x00000001);\n 25 # output: report(0xd9c787c1);\n 26 # output: \n 27 # output: report(0xb38f0f83);\n 28 # output: report(0x00000004);\n 29 # output: report(0x3b38f0f8);\n 30 # output: \n 31 # output: report(0xb38f0f83);\n 32 # output: report(0x00000010);\n 33 # output: report(0x0f83b38f);\n 34 # output: \n 35 # output: report(0xb38f0f83);\n 36 # output: report(0x0000001f);\n 37 # output: report(0x671e1f07);\n 38 # output: \n 39 # output: report(0xb38f0f83);\n 40 # output: report(0x00000021);\n 41 # output: report(0xd9c787c1);\n 42 # output: \n 43 # output: report(0xb38f0f83);\n 44 # output: report(0x00002224);\n 45 # output: report(0x3b38f0f8);\n 46 # output: \n 47 # output: report(0xb38f0f83);\n 48 # output: report(0x00f789f0);\n 49 # output: report(0x0f83b38f);\n 50 # output: \n 51 # output: report(0xb38f0f83);\n 52 # output: report(0xffffffff);\n 53 # output: report(0x671e1f07);\n 54 # output: \n 55 # output: report(0xb38f0f83);\n 56 # output: report(0x00000000);\n 57 # output: report(0xb38f0f83);\n 58 # output: \n 59 # output: report(0xb38f0f83);\n 60 # output: report(0x00000001);\n 61 # output: report(0xd9c787c1);\n 62 # output: \n 63 # output: report(0xb38f0f83);\n 64 # output: report(0x00000004);\n 65 # output: report(0x3b38f0f8);\n 66 # output: \n 67 # output: report(0xb38f0f83);\n 68 # output: report(0x00000010);\n 69 # output: report(0x0f83b38f);\n 70 # output: \n 71 # output: report(0xb38f0f83);\n 72 # output: report(0x0000001f);\n 73 # output: report(0x671e1f07);\n 74 # output: \n 75 # output: report(0xb38f0f83);\n 76 # output: report(0x00000021);\n 77 # output: report(0xd9c787c1);\n 78 # output: \n 79 # output: report(0xb38f0f83);\n 80 # output: report(0x00000024);\n 81 # output: report(0x3b38f0f8);\n 82 # output: \n 83 # output: report(0xb38f0f83);\n 84 # output: report(0x00000030);\n 85 # output: report(0x0f83b38f);\n 86 # output: \n 87 # output: report(0xb38f0f83);\n 88 # output: report(0x0000003f);\n 89 # output: report(0x671e1f07);\n 90 # output: \n 91 # output: exit(0)\n 92 93 #include "or1k-asm-test-env.h" 94 95 .macro TEST_ROR op1, op2, res 96 /* Note that 'res' is not used here. We could stop using the 97 .TestResults file and use 'res' here instead. */ 98 LOAD_IMMEDIATE r5, \op1 99 LOAD_IMMEDIATE r6, \op2 100 REPORT_REG_TO_CONSOLE r5 101 REPORT_REG_TO_CONSOLE r6 102 l.ror r4, r5, r6 103 REPORT_REG_TO_CONSOLE r4 104 PRINT_NEWLINE_TO_CONSOLE 105 .endm 106 107 .macro TEST_RORI op1, op2, res 108 /* Note that 'res' is not used here. We could stop using the 109 .TestResults file and use 'res' here instead. */ 110 LOAD_IMMEDIATE r5, \op1 111 REPORT_REG_TO_CONSOLE r5 112 REPORT_IMMEDIATE_TO_CONSOLE \op2 113 l.rori r4, r5, \op2 114 REPORT_REG_TO_CONSOLE r4 115 PRINT_NEWLINE_TO_CONSOLE 116 .endm 117 118 STANDARD_TEST_ENVIRONMENT 119 120 .section .text 121 start_tests: 122 PUSH LINK_REGISTER_R9 123 124 /* Test the l.ror instruction. */ 125 126 /* Rotate by zero */ 127 TEST_ROR 0xb38f0f83, 0x00000000, 0xb38f0f83 128 129 /* Rotate by amounts in the 1 - 31 range. */ 130 TEST_ROR 0xb38f0f83, 0x00000001, 0xd9c787c1 131 TEST_ROR 0xb38f0f83, 0x00000004, 0x3b38f0f8 132 TEST_ROR 0xb38f0f83, 0x00000010, 0x0f83b38f 133 TEST_ROR 0xb38f0f83, 0x0000001f, 0x671e1f07 134 135 /* Rotate by larger amounts - should be masked. */ 136 TEST_ROR 0xb38f0f83, 0x00000021, 0xd9c787c1 137 TEST_ROR 0xb38f0f83, 0x00002224, 0x3b38f0f8 138 TEST_ROR 0xb38f0f83, 0x00f789f0, 0x0f83b38f 139 TEST_ROR 0xb38f0f83, 0xffffffff, 0x671e1f07 140 141 /* Test the l.rori instruction. */ 142 143 /* Rotate by zero */ 144 TEST_RORI 0xb38f0f83, 0x00000000, 0xb38f0f83 145 146 /* Rotate by amounts in the 1 - 31 range. */ 147 TEST_RORI 0xb38f0f83, 0x01, 0xd9c787c1 148 TEST_RORI 0xb38f0f83, 0x04, 0x3b38f0f8 149 TEST_RORI 0xb38f0f83, 0x10, 0x0f83b38f 150 TEST_RORI 0xb38f0f83, 0x1f, 0x671e1f07 151 152 /* Rotate by larger amounts (32 - 63) - should be masked. */ 153 TEST_RORI 0xb38f0f83, 0x21, 0xd9c787c1 154 TEST_RORI 0xb38f0f83, 0x24, 0x3b38f0f8 155 TEST_RORI 0xb38f0f83, 0x30, 0x0f83b38f 156 TEST_RORI 0xb38f0f83, 0x3f, 0x671e1f07 157 158 POP LINK_REGISTER_R9 159 RETURN_TO_LINK_REGISTER_R9 160