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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 115 jeremybenn
/* is-find.test.S. l.ff1 and l.fl1 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
27
 *
28
 * A simple rising stack is provided starting at _stack and pointed to by
29
 * r1. r1 points to the next free word. Only 32-bit registers may be pushed
30
 * onto the stack.
31
 *
32
 * Local labels up to 49 are reserved for macros. Each is used only once in
33
 * all macros. You can get in a serious mess if you get local label clashing
34
 * in macros.
35
 *
36
 * Arguments to functions are passed in r3 through r8.
37
 * r9 is the link (return address)
38
 * r11 is for returning results
39
 *
40
 * Only r1 and r2 are preserved across function calls. It is up to the callee
41
 * to save any other registers required.
42
 * ------------------------------------------------------------------------- */
43
 
44
/* ----------------------------------------------------------------------------
45
 * Test coverage
46
 *
47
 * The l.ff1 and l.fl1 should fine the first and last bits in a register
48
 * respectively.
49
 *
50
 * Problems in this area were reported in Bug 1772. Having fixed the problem,
51
 * this is (in good software engineering style), a  regression test to go with
52
 * the fix.
53
 *
54
 * This is not a comprehensive test of any instruction (yet).
55
 *
56
 * Of course what is really needed is a comprehensive instruction test...
57
 * ------------------------------------------------------------------------- */
58
 
59
 
60
#include "inst-set-test.h"
61
 
62
/* ----------------------------------------------------------------------------
63
 * A macro to carry out a test of find
64
 *
65
 * Arguments
66
 *   opc:       The opcode
67
 *   op:        First operand value
68
 *   res:       Expected result
69
 *   str:       Output string
70
 * ------------------------------------------------------------------------- */
71
#define TEST_FIND(opc, op, res, str)                                     \
72
        LOAD_CONST (r4,33)              /* Invalid result */            ;\
73
        LOAD_CONST (r5,op)              /* Load number to analyse */    ;\
74
        opc     r4,r5                                           ;\
75
        CHECK_RES (str, r4, res)
76
 
77
 
78
        .section .text
79
        .global _start
80
_start:
81
 
82
/* ----------------------------------------------------------------------------
83
 * Test of find first 1, l.ff1
84
 * ------------------------------------------------------------------------- */
85
_ff1:
86
        LOAD_STR (r3, "l.ff1\n")
87
        l.jal   _puts
88
        l.nop
89
 
90
        /* Try a range of candidates. */
91
        TEST_FIND (l.ff1, 0x00000001,  1, "ff1 (0x00000001) =  1: ")
92
        TEST_FIND (l.ff1, 0x80000000, 32, "ff1 (0x80000000) = 32: ")
93
        TEST_FIND (l.ff1, 0x55555555,  1, "ff1 (0x55555555) =  1: ")
94
        TEST_FIND (l.ff1, 0xaaaaaaaa,  2, "ff1 (0xaaaaaaaa) =  2: ")
95
        TEST_FIND (l.ff1, 0x00018000, 16, "ff1 (0x00018000) = 16: ")
96
        TEST_FIND (l.ff1, 0xc0000000, 31, "ff1 (0xc0000000) = 31: ")
97
        TEST_FIND (l.ff1, 0x00000000,  0, "ff1 (0x00000000) =  0: ")
98
 
99
/* ----------------------------------------------------------------------------
100
 * Test of find first 1, l.fl1
101
 * ------------------------------------------------------------------------- */
102
_fl1:
103
        LOAD_STR (r3, "l.fl1\n")
104
        l.jal   _puts
105
        l.nop
106
 
107
        /* Try a range of candidates. */
108
        TEST_FIND (l.fl1, 0x00000001,  1, "fl1 (0x00000001) =  1: ")
109
        TEST_FIND (l.fl1, 0x80000000, 32, "fl1 (0x80000000) = 32: ")
110
        TEST_FIND (l.fl1, 0x55555555, 31, "fl1 (0x55555555) = 31: ")
111
        TEST_FIND (l.fl1, 0xaaaaaaaa, 32, "fl1 (0xaaaaaaaa) = 32: ")
112
        TEST_FIND (l.fl1, 0x00018000, 17, "fl1 (0x00018000) = 17: ")
113
        TEST_FIND (l.fl1, 0xc0000000, 32, "fl1 (0xc0000000) = 32: ")
114
        TEST_FIND (l.fl1, 0x00000000,  0, "fl1 (0x00000000) =  0: ")
115
 
116
/* ----------------------------------------------------------------------------
117
 * All done
118
 * ------------------------------------------------------------------------- */
119
_exit:
120
        LOAD_STR (r3, "Test completed\n")
121
        l.jal   _puts
122
        l.nop
123
 
124
        TEST_EXIT

powered by: WebSVN 2.1.0

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