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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 107 jeremybenn
/* is-div-test.S. l.div and l.divu 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 116 jeremybenn
 * Coding conventions are described in inst-set-test.S
27 107 jeremybenn
 * ------------------------------------------------------------------------- */
28
 
29
/* ----------------------------------------------------------------------------
30
 * Test coverage
31
 *
32
 * The l.div and l.divu instructions should set the carry flag as well as
33
 * triggering an event when divide by zero occurs.
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
 * Test of divide l.div
48
 * ------------------------------------------------------------------------- */
49
 
50
        .section .text
51
        .global _start
52
_start:
53
        /* Signed divide by zero */
54
_div:
55
        LOAD_STR (r3, "l.div\n")
56
        l.jal   _puts
57
        l.nop
58
 
59
        LOAD_CONST (r2, ~SPR_SR_CY)     /* Clear the carry flag */
60
        l.mfspr r3,r0,SPR_SR
61
        l.and   r3,r3,r2
62
        l.mtspr r0,r3,SPR_SR
63
 
64
        LOAD_CONST (r5,1)               /* Set up args for division */
65
        LOAD_CONST (r6,0)
66
        l.div   r4,r5,r6
67
 
68
        l.mfspr r2,r0,SPR_SR            /* So we can examine the carry flag */
69
        LOAD_CONST (r4, SPR_SR_CY)      /* The carry bit */
70
        l.and   r2,r2,r4
71
        l.sfeq  r2,r4
72
        CHECK_FLAG ("1 / 0 (with error) carry flag set: ", TRUE)
73
 
74
        /* Signed divide by zero */
75
_divu:
76
        LOAD_STR (r3, "l.divu\n")
77
        l.jal   _puts
78
        l.nop
79
 
80
        LOAD_CONST (r2, ~SPR_SR_CY)     /* Clear the carry flag */
81
        l.mfspr r3,r0,SPR_SR
82
        l.and   r3,r3,r2
83
        l.mtspr r0,r3,SPR_SR
84
 
85
        LOAD_CONST (r5,1)               /* Set up args for division */
86
        LOAD_CONST (r6,0)
87
        l.divu  r4,r5,r6
88
 
89
        l.mfspr r2,r0,SPR_SR            /* So we can examine the carry flag */
90
        LOAD_CONST (r4, SPR_SR_CY)      /* The carry bit */
91
        l.and   r2,r2,r4
92
        l.sfeq  r2,r4
93
        CHECK_FLAG ("1 / 0 (with error) carry flag set: ", TRUE)
94
 
95
/* ----------------------------------------------------------------------------
96
 * All done
97
 * ------------------------------------------------------------------------- */
98
_exit:
99
        LOAD_STR (r3, "Test completed\n")
100
        l.jal   _puts
101
        l.nop
102
 
103
        TEST_EXIT

powered by: WebSVN 2.1.0

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