Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / sim / testsuite / or1k / mfspr.S
blob345c936873dc2db61e3d2833898311ba302f025b
1 /* Tests instructions l.mfspr and l.mtspr.
3    Copyright (C) 2017-2023 Free Software Foundation, Inc.
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.
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.
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/>.  */
18 # mach: or1k
19 # output: report(0x00000000);\n
20 # output: report(0x00002801);\n
21 # output: report(0xdeadbeef);\n
22 # output: \n
23 # output: report(0x00002801);\n
24 # output: report(0x00000000);\n
25 # output: report(0xdeadbeef);\n
26 # output: \n
27 # output: report(0x00002801);\n
28 # output: report(0x00002801);\n
29 # output: report(0xdeadbeef);\n
30 # output: \n
31 # output: report(0x00000801);\n
32 # output: report(0x00002000);\n
33 # output: report(0xdeadbeef);\n
34 # output: \n
35 # output: report(0x00002000);\n
36 # output: report(0x00000801);\n
37 # output: report(0xdeadbeef);\n
38 # output: \n
39 # output: report(0x00002801);\n
40 # output: report(0x00000001);\n
41 # output: report(0xdeadbeef);\n
42 # output: \n
43 # output: report(0x00000800);\n
44 # output: report(0x00002801);\n
45 # output: report(0xdeadbeef);\n
46 # output: \n
47 # output: report(0x00000000);\n
48 # output: report(0x00002801);\n
49 # output: report(0xdeadbeef);\n
50 # output: \n
51 # output: report(0x00002801);\n
52 # output: report(0x00000000);\n
53 # output: report(0xdeadbeef);\n
54 # output: \n
55 # output: report(0x00002801);\n
56 # output: report(0x00002801);\n
57 # output: report(0xdeadbeef);\n
58 # output: \n
59 # output: report(0x00000801);\n
60 # output: report(0x00002000);\n
61 # output: report(0xdeadbeef);\n
62 # output: \n
63 # output: report(0x00002000);\n
64 # output: report(0x00000801);\n
65 # output: report(0xdeadbeef);\n
66 # output: \n
67 # output: report(0x00002801);\n
68 # output: report(0x00000001);\n
69 # output: report(0xdeadbeef);\n
70 # output: \n
71 # output: report(0x00000800);\n
72 # output: report(0x00002801);\n
73 # output: report(0xdeadbeef);\n
74 # output: \n
75 # output: exit(0)\n
77 #include "or1k-asm-test-env.h"
79 #define MACLO_VAL 0xdeadbeef
81         /* A macro to carry out a test of l.mfspr.
83            MACLO (0x2801) is used as the SPR, since it can be read and
84            cleared using l.macrc and can be set using l.maci.  spr_number
85            and immediate_val_to_or should be chosen to address this
86            register.
88            The value placed in the register is entirely arbitrary - we use
89            0xdeadbeef.  */
91         .macro TEST_MFSPR  spr_number, immediate_val_to_or
92         REPORT_IMMEDIATE_TO_CONSOLE \spr_number
93         REPORT_IMMEDIATE_TO_CONSOLE \immediate_val_to_or
94         /* Write MACLO_VAL to MACLO.  */
95         l.macrc r2
96         LOAD_IMMEDIATE r2, MACLO_VAL
97         l.maci  r2, 1
98         LOAD_IMMEDIATE r5, \spr_number
99         l.mfspr r4, r5, \immediate_val_to_or
100         REPORT_REG_TO_CONSOLE r4
101         PRINT_NEWLINE_TO_CONSOLE
102         .endm
104         /* A macro to carry out a test of l.mtspr
106            MACLO (0x2801) is used as the SPR, since it can be read and
107            cleared using l.macrc and can be set using l.maci.  The
108            arguments spr_number and immediate_val_to_or should be chosen
109            to address this register.
111            The value placed in the register is entirely arbitrary - we use
112            0xdeadbeef.  */
114         .macro TEST_MTSPR  spr_number, immediate_val_to_or
115         REPORT_IMMEDIATE_TO_CONSOLE \spr_number
116         REPORT_IMMEDIATE_TO_CONSOLE \immediate_val_to_or
117         /* Clear MACLO  */
118         l.macrc r2
119         LOAD_IMMEDIATE r4, MACLO_VAL
120         LOAD_IMMEDIATE r5, \spr_number
121         l.mtspr r5, r4, \immediate_val_to_or
122         /* Retrieve MACLO.  */
123         l.macrc r4
124         REPORT_REG_TO_CONSOLE r4
125         PRINT_NEWLINE_TO_CONSOLE
126         .endm
128         STANDARD_TEST_ENVIRONMENT
130         .section .text
131 start_tests:
132         PUSH LINK_REGISTER_R9
134         /* Test the l.mfspr instruction with a range of operands.  */
136         /* Move a test value using zero in the register.  */
137         TEST_MFSPR SPR_VR, SPR_MACLO /* 0x0000, 0x2801  */
139         /* Move a test value using zero as the constant.  */
140         TEST_MFSPR SPR_MACLO, SPR_VR /* 0x2801, 0x0000  */
142         /* Move a test value using non-zero in both register and constant.  */
144         /* Some of these values will not give the correct result if OR
145            rather than ADD is used to determine the SPR address.  */
146         TEST_MFSPR SPR_MACLO,  SPR_MACLO /* 0x2801, 0x2801  */
147         TEST_MFSPR SPR_DMMUPR, SPR_ICCR /* 0x0801, 0x2000  */
148         TEST_MFSPR SPR_ICCR,   SPR_DMMUPR /* 0x2000, 0x0801  */
149         TEST_MFSPR SPR_MACLO,  SPR_UPR /* 0x2801, 0x0001  */
150         TEST_MFSPR SPR_DMMUCR, SPR_MACLO /* 0x0800, 0x2801  */
152         /* Test the l.mtspr instruction with a range of operands.  */
154         /* Move a test value using zero in the register.  */
155         TEST_MTSPR SPR_VR, SPR_MACLO /* 0x0000, 0x2801  */
157         /* Move a test value using zero as the constant.  */
158         TEST_MTSPR SPR_MACLO, SPR_VR /* 0x2801, 0x0000  */
160         /* Move a test value using non-zero in both register and constant.  */
162         /* Some of these values will not give the correct result if or
163            rather than add is used to determine the SPR address.  */
164         TEST_MTSPR SPR_MACLO,  SPR_MACLO /* 0x2801, 0x2801  */
165         TEST_MTSPR SPR_DMMUPR, SPR_ICCR /* 0x0801, 0x2000  */
166         TEST_MTSPR SPR_ICCR,   SPR_DMMUPR /* 0x2000, 0x0801  */
167         TEST_MTSPR SPR_MACLO,  SPR_UPR /* 0x2801, 0x0001  */
168         TEST_MTSPR SPR_DMMUCR, SPR_MACLO /* 0x0800, 0x2801  */
170         POP LINK_REGISTER_R9
171         RETURN_TO_LINK_REGISTER_R9