OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [inst-set-test/] [is-jump-test.S] - Blame information for rev 346

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 121 jeremybenn
/* is-jump-test.S. l.j, l.jal, l.jalr and l.jr instruction test of Or1ksim
2
 *
3
 * Copyright (C) 1999-2006 OpenCores
4
 * Copyright (C) 2010 Embecosm Limited
5
 *
6
 * Contributors various OpenCores participants
7
 * Contributor Jeremy Bennett 
8
 *
9
 * This file is part of OpenRISC 1000 Architectural Simulator.
10
 *
11
 * This program is free software; you can redistribute it and/or modify it
12
 * under the terms of the GNU General Public License as published by the Free
13
 * Software Foundation; either version 3 of the License, or (at your option)
14
 * any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful, but WITHOUT
17
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19
 * more details.
20
 *
21
 * You should have received a copy of the GNU General Public License along
22
 * with this program.  If not, see .
23
 */
24
 
25
/* ----------------------------------------------------------------------------
26
 * Coding conventions are described in inst-set-test.S
27
 * ------------------------------------------------------------------------- */
28
 
29
/* ----------------------------------------------------------------------------
30
 * Test coverage
31
 *
32
 * The l.jalr and l.jr instructions should trigger an alignment exception if
33
 * the register does not holde an aligned address (Bug 1775).
34
 *
35
 * Having fixed the problem, this is (in good software engineering style), a
36
 * regresison test to go with the fix.
37
 *
38
 * This is not a comprehensive test of either instruction (yet).
39
 *
40
 * Of course what is really needed is a comprehensive instruction test...
41
 * ------------------------------------------------------------------------- */
42
 
43
 
44
#include "inst-set-test.h"
45
 
46
/* ----------------------------------------------------------------------------
47
 * A macro to carry out a test of a jump using a register destination
48
 *
49
 * We manually construct the opcode, to allow us to force r9 into the
50
 * destination field, to test exception handling. Usually the assembler would
51
 * prevent this.
52
 *
53
 * Arguments
54
 *   opc_mask:  The opcode mask
55
 *   regno:     Register number to use
56
 *   offset:    Offset in bytes forward of target (testing alignment
57
 * ------------------------------------------------------------------------- */
58
#define TEST_JUMP(opc_mask, dest, offset)                                \
59
        LOAD_CONST (r31,51f + offset)                                   ;\
60
        .word   (0xe01f0004|(dest << 21))       /* l.ori rD,r31,r0 */   ;\
61
        l.mtspr r0,r0,SPR_EPCR_BASE     /* Clear record */              ;\
62
50:     .word   (opc_mask|(dest << 11)) /* Jump opcode */               ;\
63
        l.nop                                                           ;\
64
                                                                        ;\
65
        /* Jump failed, we drop through to here */                      ;\
66
        l.mfspr r2,r0,SPR_EPCR_BASE     /* What triggered exception */  ;\
67
        PUSH (r2)                       /* Save EPCR for later */       ;\
68
        PUTS ("  Jump to 0x")                                           ;\
69
        PUTH (51f + offset)                                             ;\
70
        PUTS (" using register 0x")                                     ;\
71
        PUTHQ (dest)                                                    ;\
72
        PUTS (" failed\n")                                              ;\
73
        l.j     52f                                                     ;\
74
        l.nop                                                           ;\
75
                                                                        ;\
76
        /* Jump succeeded we get here */                                ;\
77
51:     l.mfspr r2,r0,SPR_EPCR_BASE     /* What triggered exception */  ;\
78
        PUSH (r2)                       /* Save EPCR for later */       ;\
79
        PUTS ("  Jump to 0x")                                           ;\
80
        PUTH (51b + offset)                                             ;\
81
        PUTS (" using register 0x")                                     ;\
82
        PUTHQ (dest)                                                    ;\
83
        PUTS (" OK\n")                                                  ;\
84
                                                                        ;\
85
        /* Report if we got exception */                                ;\
86
52:     POP (r2)                        /* Retrieve EPCR */             ;\
87
        LOAD_CONST (r4, 50b)            /* The opcode of interest */    ;\
88
        l.and   r2,r2,r4                                                ;\
89
        l.sfeq  r2,r4                                                   ;\
90
        l.bnf   53f                                                     ;\
91
                                                                        ;\
92
        PUTS ("  - exception triggered: TRUE\n")                        ;\
93
        l.j     54f                                                     ;\
94
        l.nop                                                           ;\
95
                                                                        ;\
96
53:     PUTS ("  - exception triggered: FALSE\n")                       ;\
97
54:
98
 
99
 
100
/* ----------------------------------------------------------------------------
101
 * Start of code
102
 * ------------------------------------------------------------------------- */
103
        .section .text
104
        .global _start
105
_start:
106
 
107
/* ----------------------------------------------------------------------------
108
 * Test of jump and link register, l.jalr
109
 * ------------------------------------------------------------------------- */
110
_jalr:
111
        LOAD_STR (r3, "l.jalr\n")
112
        l.jal   _puts
113
        l.nop
114
 
115
        /* Test with various alignment offsets */
116
        TEST_JUMP (0x48000000, 5, 0)            /* No offset */
117
        TEST_JUMP (0x48000000, 5, 1)            /* No offset */
118
        TEST_JUMP (0x48000000, 5, 2)            /* No offset */
119
        TEST_JUMP (0x48000000, 5, 3)            /* No offset */
120
 
121
        /* Test with link register as the destination */
122
        TEST_JUMP (0x48000000, 9, 0)            /* No offset */
123
 
124
/* ----------------------------------------------------------------------------
125
 * Test of jump register, l.jr
126
 * ------------------------------------------------------------------------- */
127
_jr:
128
        LOAD_STR (r3, "l.jr\n")
129
        l.jal   _puts
130
        l.nop
131
 
132
        /* Test with various alignment offsets */
133
        TEST_JUMP (0x44000000, 5, 0)                    /* No offset */
134
        TEST_JUMP (0x44000000, 5, 1)                    /* No offset */
135
        TEST_JUMP (0x44000000, 5, 2)                    /* No offset */
136
        TEST_JUMP (0x44000000, 5, 3)                    /* No offset */
137
 
138
        /* Test with link register as the destination (OK here) */
139
        TEST_JUMP (0x44000000, 9, 0)                    /* No offset */
140
 
141
/* ----------------------------------------------------------------------------
142
 * All done
143
 * ------------------------------------------------------------------------- */
144
_exit:
145
        LOAD_STR (r3, "Test completed\n")
146
        l.jal   _puts
147
        l.nop
148
 
149
        TEST_EXIT

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.