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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-linkregtest.S] - Blame information for rev 714

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

Line No. Rev Author Line
1 349 julius
/*
2
 
3
        Tests of link register behavior in delay slot of l.jal instruction
4
 
5
        Testing this:
6
        l.jal _place
7
        l.sw 4(r1) r9
8
        What happens...... (r9 is link register)
9
Result:
10
        Appears to confirm that the r9 becomes the return value immediately
11
        ( at the write-back stage of the l.jal instruction)
12
 
13
        Then testing this:
14
        l.jal _place
15
        l.or r9, r0, r0
16
Result:
17
        Writing to link register (r9) in delay slot works, so should be
18
        avoided (it was illegal according to spec, anyway)
19
 
20
*/
21
//////////////////////////////////////////////////////////////////////
22
////                                                              ////
23
//// Copyright (C) 2010 Authors and OPENCORES.ORG                 ////
24
////                                                              ////
25
//// This source file may be used and distributed without         ////
26
//// restriction provided that this copyright statement is not    ////
27
//// removed from the file and that any derivative work contains  ////
28
//// the original copyright notice and the associated disclaimer. ////
29
////                                                              ////
30
//// This source file is free software; you can redistribute it   ////
31
//// and/or modify it under the terms of the GNU Lesser General   ////
32
//// Public License as published by the Free Software Foundation; ////
33
//// either version 2.1 of the License, or (at your option) any   ////
34
//// later version.                                               ////
35
////                                                              ////
36
//// This source is distributed in the hope that it will be       ////
37
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
38
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
39
//// PURPOSE.  See the GNU Lesser General Public License for more ////
40
//// details.                                                     ////
41
////                                                              ////
42
//// You should have received a copy of the GNU Lesser General    ////
43
//// Public License along with this source; if not, download it   ////
44
//// from http://www.opencores.org/lgpl.shtml                     ////
45
////                                                              ////
46
//////////////////////////////////////////////////////////////////////
47
 
48
 
49
#include "spr-defs.h"
50
#include "board.h"
51
 
52
/* =================================================== [ exceptions ] === */
53
        .section .vectors, "ax"
54
 
55
 
56
/* ---[ 0x100: RESET exception ]----------------------------------------- */
57
        .org 0x100
58
        l.movhi r0, 0
59
        /* Clear status register */
60
        l.ori   r1, r0, SPR_SR_SM
61
        l.mtspr r0, r1, SPR_SR
62
        /* Clear timer  */
63
        l.mtspr r0, r0, SPR_TTMR
64
        /* Init the stack */
65
        .global _stack
66
        l.movhi r1, hi(_stack)
67
        l.ori   r1, r1, lo(_stack)
68
        l.addi  r2, r0, -3
69
        l.and   r1, r1, r2
70
        /* Jump to program initialisation code */
71
        .global _start
72
        l.movhi r4, hi(_start)
73
        l.ori   r4, r4, lo(_start)
74
        l.jr    r4
75
        l.nop
76
 
77
 
78
/* =================================================== [ text ] === */
79
        .section .text
80
 
81
/* =================================================== [ start ] === */
82
 
83
        .global _start
84
        .global _testjalfunc
85
_start:
86
        l.addi  r1, r1, -4
87
        l.movhi r9, hi(0x01234567)
88
        l.ori   r9, r9, lo(0x01234567)
89
        l.or    r3, r1, r1 /* copy stack pointer to r3 so we can report it */
90
        l.nop   0x2
91
        l.jal   _testjalfunc
92
        l.sw    0(r1), r9
93
        l.nop
94
        l.nop
95
        l.movhi r3, hi(0x8000000d)
96
        l.ori   r3, r3, lo(0x8000000d)
97 425 julius
        /* Setup some code at address 0x0 */
98 349 julius
        l.movhi r4, hi(0x15000000) /* standard l.nop */
99 425 julius
        l.ori   r5, r4, 0x2 /* l.nop that will report value in r3 */
100
        l.sw    0x0(r0), r5 /* Write "l.nop 0x2" to 0x0 */
101
        l.movhi r6, hi(0xa8600000) /*Assemble register with l.ori r3,r0,0 */
102
        l.sw    0x4(r0), r6 /* Write "l.ori r3,r0,0" to 0x4*/
103 349 julius
        l.ori   r5, r4, 0x1 /* l.nop that will exit simulation */
104 425 julius
        l.sw    0x8(r0), r5 /* Write l.nop 0x1 to 0x8 */
105
        l.sw    0xc(r0), r0 /* Write "l.j 0" to address 0xc */
106
        l.sw    0x10(r0), r4 /* Write l.nop to 0xc */
107 349 julius
        l.nop
108 425 julius
        /* Try writing to r9 during delay slot... */
109 349 julius
        l.jal   _testjalfunc
110 425 julius
        l.or    r9, r0, r0 /* Clear r9 - cause jump to 0 on return */
111 349 julius
        l.nop   1
112
 
113
 
114
_testjalfunc:
115
        l.nop
116
        l.nop
117
        l.nop
118
        l.nop
119
        l.nop
120
        l.jr    r9
121
        l.nop
122
 

powered by: WebSVN 2.1.0

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