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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [change_mode.S] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 csantifort
/*****************************************************************
2
//                                                              //
3
//  Amber 2 Core Instruction Test                               //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Tests teq, tst, cmp and cmn with the p flag set             //
10
//  Starts in supervisor mode, changes to Interrupt mode,       //
11
//  then Fast Interrupt mode, then supervisor mode again        //
12
//  and finally User mode                                       //
13
//                                                              //
14
//  Author(s):                                                  //
15
//      - Conor Santifort, csantifort.amber@gmail.com           //
16
//                                                              //
17
//////////////////////////////////////////////////////////////////
18
//                                                              //
19
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
20
//                                                              //
21
// This source file may be used and distributed without         //
22
// restriction provided that this copyright statement is not    //
23
// removed from the file and that any derivative work contains  //
24
// the original copyright notice and the associated disclaimer. //
25
//                                                              //
26
// This source file is free software; you can redistribute it   //
27
// and/or modify it under the terms of the GNU Lesser General   //
28
// Public License as published by the Free Software Foundation; //
29
// either version 2.1 of the License, or (at your option) any   //
30
// later version.                                               //
31
//                                                              //
32
// This source is distributed in the hope that it will be       //
33
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
34
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
35
// PURPOSE.  See the GNU Lesser General Public License for more //
36
// details.                                                     //
37
//                                                              //
38
// You should have received a copy of the GNU Lesser General    //
39
// Public License along with this source; if not, download it   //
40
// from http://www.opencores.org/lgpl.shtml                     //
41
//                                                              //
42
*****************************************************************/
43
 
44
#include "amber_registers.h"
45
 
46
        .section .text
47
        .globl  main
48
main:
49
        @ ------------------------------------------------------------
50
        @ Change to Interrupt mode using tstp
51
        @ tstp does an AND
52
        mov     r4, #0xfffffffe
53
        @ When the pc is in the rn position, it includes the status bits
54
        tstp    r4, pc
55
 
56
        @ Check that we're now in Interrupt mode
57
        mov     r5, pc
58
        @ just want the mode bits
59
        and     r5, r5, #0x3
60
        cmp     r5, #2
61
        movne   r10, #50
62
        bne     testfail
63
 
64
        @ ------------------------------------------------------------
65
        @ Change to Fast Interrupt mode using cmpp
66
        @ cmpp does a subtract
67
        mov     r6, pc
68
        cmpp    r6, #1
69
        mov     r7, pc
70
        and     r8, r7, #3
71
        cmp     r8, #1
72
        movne   r10, #60
73
        bne     testfail
74
 
75
        @ ------------------------------------------------------------
76
        @ Change back to Supervisor mode using cmnp
77
        @ cmnp does an add
78
        ldr     r1, Status1
79
        cmnp    pc, #0xf0000003
80
        nop
81
        mov     r9, pc
82
        ldr     r0, PCMask
83
        bic     r13, r9, r0
84
        cmp     r13, r1
85
        movne   r10, #70
86
        bne     testfail
87
 
88
        @ ------------------------------------------------------------
89
        @ Clear all the status bits and change to user mode
90
        @ teq does an XOR
91
        teqp    pc, #0
92
        b       1f
93
        b       testfail
94
        b       testfail
95
 
96
        @ Check that all the status bits are now zero
97
1:      ldr     r0, PCMask
98
        mov     r1, pc
99
        bics    r1, r1, r0
100
        movne   r10, #10
101
        bne     testfail
102
 
103
        @ ------------------------------------------------------------
104
        @ Now in user mode, so can't change back to supervisor mode
105
        @ But can set the condition flags
106
        teqp    pc, #0xf0000003
107
        mov     r2, #0
108
        orr     r1, r2, pc
109
        bic     r1, r1, r0
110
        cmp     r1, #0xf0000000
111
        movne   r10, #20
112
        bne     testfail
113
 
114
        b       testpass
115
 
116
testfail:
117
        ldr     r11, AdrTestStatus
118
        str     r10, [r11]
119
        b       testfail
120
 
121
testpass:
122
        ldr     r11, AdrTestStatus
123
        mov     r10, #17
124
        str     r10, [r11]
125
        b       testpass
126
 
127
 
128
/* Write 17 to this address to generate a Test Passed message */
129
AdrTestStatus:  .word  ADR_AMBER_TEST_STATUS
130
PCMask:         .word  0x03fffffc
131
Status1:        .word  0xf0000003
132
 
133
/* ========================================================================= */
134
/* ========================================================================= */
135
 
136
 

powered by: WebSVN 2.1.0

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