1 /* Tests some basic CPU instructions.
3 Copyright (C) 2017-2024 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/>. */
19 # output: report(0xffff0012);\n
20 # output: report(0x12352af7);\n
21 # output: report(0x7ffffffe);\n
22 # output: report(0xffffa5a7);\n
23 # output: report(0x000fffff);\n
24 # output: report(0x00002800);\n
25 # output: report(0x00000009);\n
26 # output: report(0xdeaddead);\n
27 # output: report(0xffff0000);\n
28 # output: report(0x12345678);\n
29 # output: report(0xabcdf0bd);\n
32 #include "or1k-asm-test-env.h"
34 #define FIRST_RAM_ADDR 0x00000000
38 /* Early test begin. */
40 /* Do this test upfront, as it modifies STACK_POINTER_R1. */
50 l.addi r9 , r8 , 0x100
51 l.addi r10, r9 , 0x200
52 l.addi r11, r10, 0x400
53 l.addi r12, r11, 0x800
54 l.addi r13, r12, 0x1000
55 l.addi r14, r13, 0x2000
56 l.addi r15, r14, 0x4000
57 l.addi r16, r15, 0x8000
76 /* We cannot use REPORT_REG_TO_CONSOLE here, as the stack is not
78 MOVE_REG NOP_REPORT_R3, r16
79 REPORT_TO_CONSOLE /* Should be 0xffff0012 */
89 /* Read and write from RAM. */
91 LOAD_IMMEDIATE r31, FIRST_RAM_ADDR
142 REPORT_REG_TO_CONSOLE r8 /* Should be 0x12352af7 */
148 /* Test arithmetic operations. */
166 REPORT_REG_TO_CONSOLE r8 /* Should be 0x7ffffffe */
172 /* Test logical operations. */
189 REPORT_REG_TO_CONSOLE r8 /* Should be 0xffffa5a7 */
195 /* Test shifting operations. */
212 REPORT_REG_TO_CONSOLE r8 /* Should be 0x000fffff */
218 /* Test the CPU flag. */
424 REPORT_REG_TO_CONSOLE r8 /* Should be 0x00002800 */
430 /* Test the jump instructions. */
435 OR1K_INST (l.addi r8,r8,1),
440 OR1K_INST (l.addi r8,r8,1),
445 OR1K_INST (l.addi r8,r8,1),
446 OR1K_INST (l.jal _T2)
451 OR1K_INST (l.addi r8,r8,1),
457 OR1K_INST (l.addi r8,r8,1),
465 OR1K_INST (l.addi r8,r8,1),
466 OR1K_INST (l.bnf _T5)
473 OR1K_INST (l.addi r8,r8,1),
474 OR1K_INST (l.bnf _T6)
479 _T6: l.movhi r3,hi (_T7)
485 l.addi r8,r8,1 /* l.rfe should not have a delay slot */
489 _T7: REPORT_REG_TO_CONSOLE r8 /* Should be 0x000000009 */
500 REPORT_REG_TO_CONSOLE r8 /* Should be 0xdeaddead */
502 /* Test l.movhi, on 32-bit implementations it should not
503 sign-extend anything. */
506 REPORT_REG_TO_CONSOLE r3
510 LOAD_IMMEDIATE r14, 0x12345678
511 LOAD_IMMEDIATE r15, 0xABCDF0BD
513 SET_SPR_SR_FLAGS SPR_SR_F, r6, r7
515 CLEAR_SPR_SR_FLAGS SPR_SR_F, r6, r7
518 REPORT_REG_TO_CONSOLE r10
519 REPORT_REG_TO_CONSOLE r11
522 RETURN_TO_LINK_REGISTER_R9