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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [swp.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 swp and swpb                                          //
10
//                                                              //
11
//  Author(s):                                                  //
12
//      - Conor Santifort, csantifort.amber@gmail.com           //
13
//                                                              //
14
//////////////////////////////////////////////////////////////////
15
//                                                              //
16
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
17
//                                                              //
18
// This source file may be used and distributed without         //
19
// restriction provided that this copyright statement is not    //
20
// removed from the file and that any derivative work contains  //
21
// the original copyright notice and the associated disclaimer. //
22
//                                                              //
23
// This source file is free software; you can redistribute it   //
24
// and/or modify it under the terms of the GNU Lesser General   //
25
// Public License as published by the Free Software Foundation; //
26
// either version 2.1 of the License, or (at your option) any   //
27
// later version.                                               //
28
//                                                              //
29
// This source is distributed in the hope that it will be       //
30
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
31
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
32
// PURPOSE.  See the GNU Lesser General Public License for more //
33
// details.                                                     //
34
//                                                              //
35
// You should have received a copy of the GNU Lesser General    //
36
// Public License along with this source; if not, download it   //
37
// from http://www.opencores.org/lgpl.shtml                     //
38
//                                                              //
39
*****************************************************************/
40
 
41
#include "amber_registers.h"
42
 
43
        .section .text
44
        .globl  main
45
main:
46
        @ ---------------------
47
        @ swp     r2, r2, [r0]
48
        @ ---------------------
49
        ldr     r0, AdrData1
50
        mov     r2, #2
51
        swp     r2, r2, [r0]
52
 
53
        @ check the value written to memory
54
        ldr     r3, Data1
55
        cmp     r3, #2
56
        movne   r10, #10
57
        bne     testfail
58
 
59
        @ check the value read from  memory
60
        ldr     r4, Data4
61
        cmp     r4, r2
62
        movne   r10, #20
63
        bne     testfail
64
 
65
 
66
        @ ---------------------
67
        @ swpb    r2, r2, [r0]
68
        @ ---------------------
69
        ldr     r0, AdrData2
70
        add     r0, r0, #1
71
        ldr     r2, Data3
72
        swpb    r2, r2, [r0]
73
 
74
        @ check the value written to memory
75
        ldr     r3, Data2
76
        ldr     r4, Data5
77
        cmp     r3, r4
78
        movne   r10, #30
79
        bne     testfail
80
 
81
        @ check the value read from to memory
82
        mov     r5, #0xbb
83
        cmp     r2, r5
84
        movne   r10, #40
85
        bne     testfail
86
 
87
        @ ---------------------
88
        @ Test flow control, skip
89
        @ ---------------------
90
        mov     r7, #2
91
        mov     r8, #3
92
        cmp     r7, r8
93
        swpeq   r2, r2, [r0]
94
        b       check4
95
 
96
        @ these should never be executed
97
        b       testfail
98
        b       testfail
99
 
100
check4:
101
        @ check that r2 did not change
102
        cmp     r2, r5
103
        movne   r10, #50
104
        bne     testfail
105
 
106
 
107
 
108
        @ ---------------------
109
        @ Test flow control, skip first, execute second
110
        @ ---------------------
111
        ldr     r9, AdrData6
112
        mov     r7, #2
113
        mov     r8, #3
114
        cmp     r7, r8
115
        swpeq   r2, r2, [r9]
116
        swpne   r3, r3, [r9]
117
        b       check5
118
 
119
        @ these should never be executed
120
        b       testfail
121
        b       testfail
122
 
123
check5:
124
        @ check that r2 did not change
125
        cmp     r2, r5
126
        movne   r10, #60
127
        bne     testfail
128
 
129
        @ check that r3 holds correct value
130
        ldr     r8, Data7
131
        cmp     r3, r8
132
        movne   r10, #70
133
        bne     testfail
134
 
135
@ ------------------------------------------
136
@ ------------------------------------------
137
 
138
        b       testpass
139
 
140
testfail:
141
        ldr     r11, AdrTestStatus
142
        str     r10, [r11]
143
        b       testfail
144
 
145
testpass:
146
        ldr     r11, AdrTestStatus
147
        mov     r10, #17
148
        str     r10, [r11]
149
        b       testpass
150
 
151
 
152
@ put this data section here so its reachable
153
@ by the 8-bit immediate offset in LDRH
154
Data1:          .word  0x12345678
155
Data2:          .word  0xffccbbaa
156
Data3:          .word  0x01020304
157
Data4:          .word  0x12345678
158
Data5:          .word  0xffcc04aa
159
Data6:          .word  0x33445566
160
Data7:          .word  0x33445566
161
 
162
/* Write 17 to this address to generate a Test Passed message */
163
AdrTestStatus:  .word  ADR_AMBER_TEST_STATUS
164
AdrData1:       .word  Data1
165
AdrData2:       .word  Data2
166
AdrData3:       .word  Data3
167
AdrData4:       .word  Data4
168
AdrData5:       .word  Data5
169
AdrData6:       .word  Data6
170
 
171
/* ========================================================================= */
172
/* ========================================================================= */
173
 
174
 

powered by: WebSVN 2.1.0

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