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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [ldr.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 lrd and ldrb                                          //
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
/* Load Byte 0 */
48
        ldr     r0, AdrData1
49
        ldrb    r1, [r0]
50
        ldr     r2, Data2
51
        cmp     r1, r2
52
        movne   r10, #10
53
        bne     testfail
54
 
55
/* Load Byte 1 */
56
        add     r0, r0, #1
57
        ldrb    r3, [r0]
58
        ldr     r4, Data3
59
        cmp     r3, r4
60
        movne   r10, #20
61
        bne     testfail
62
 
63
/* Load Byte 2 */
64
        add     r0, r0, #1
65
        ldrb    r5, [r0]
66
        ldr     r6, Data4
67
        cmp     r5, r6
68
        movne   r10, #30
69
        bne     testfail
70
 
71
/* Load Byte 3 */
72
        add     r0, r0, #1
73
        ldrb    r7, [r0]
74
        ldr     r8, Data5
75
        cmp     r7, r8
76
        movne   r10, #40
77
        bne     testfail
78
 
79
 
80
/* Immediate offset  */
81
        ldr     r0,  AdrData1
82
        ldr     r1, [r0, #4]
83
        ldr     r3, Data2
84
        cmp     r1, r3
85
        movne   r10, #50
86
        bne     testfail
87
 
88
        @ Check that r0 is not altered
89
        ldr     r8,  AdrData1
90
        cmp     r0, r8
91
        movne   r10, #60
92
        bne     testfail
93
 
94
        /* test negative offset */
95
        ldr     r0,  AdrData8
96
        ldr     r2, [r0, #-12]
97
        ldr     r3, Data5
98
        cmp     r2, r3
99
        movne   r10, #70
100
        bne     testfail
101
 
102
        @ Check that r0 is not altered
103
        ldr     r8, AdrData8
104
        cmp     r0, r8
105
        movne   r10, #80
106
        bne     testfail
107
 
108
 
109
/* Immediate pre-indexed  */
110
        ldr     r0,  AdrData1
111
        ldr     r1, [r0, #4]!
112
 
113
        @ check that r0 was incremented correctly
114
        ldr     r8,  AdrData1
115
        add     r8, r8, #4
116
        cmp     r0, r8
117
        movne   r10, #90
118
        bne     testfail
119
 
120
        @ check that correct value was loaded into r1
121
        ldr     r2, Data2
122
        cmp     r1, r2
123
        movne   r10, #100
124
        bne     testfail
125
 
126
 
127
/* Immediate post-indexed  */
128
        ldr     r0,  AdrData1
129
        ldr     r1, [r0], #4
130
        ldr     r2, [r0], #4
131
 
132
        ldr     r3, Data1
133
        cmp     r1, r3
134
        movne   r10, #110
135
        bne     testfail
136
 
137
        ldr     r4, Data2
138
        cmp     r2, r4
139
        movne   r10, #120
140
        bne     testfail
141
 
142
        ldr     r8,  AdrData1
143
        add     r8, r8, #8
144
        cmp     r0, r8
145
        movne   r10, #130
146
        bne     testfail
147
 
148
 
149
/* Register offset  */
150
        ldr     r0,  AdrData1
151
        mov     r1,  #1
152
        ldr     r2, [r0, r1]
153
        ldr     r3, Data7
154
        cmp     r2, r3
155
        movne   r10, #140
156
        bne     testfail
157
 
158
 
159
/* Register offset pre-indexed */
160
        ldr     r0,  AdrData1
161
        mov     r1,  #3
162
        ldr     r2, [r0, r1]!
163
 
164
        ldr     r3, Data8
165
        cmp     r2, r3
166
        movne   r10, #150
167
        bne     testfail
168
 
169
        ldr     r4,  AdrData1
170
        add     r4,  r4, #3
171
        cmp     r0, r4
172
 
173
 
174
/* Register offset post-indexed */
175
        ldr     r5,  AdrData1
176
        mov     r6,  #2
177
        ldr     r7, [r5], -r6
178
 
179
        ldr     r8, Data1
180
        cmp     r7, r8
181
        movne   r10, #160
182
        bne     testfail
183
 
184
        ldr     r9,  AdrData1
185
        sub     r9, r9, #2
186
        cmp     r5, r9
187
        bne     testfail
188
 
189
 
190
/* Scaled Register offset */
191
        ldr     r0,  AdrData1
192
        mov     r1, #2
193
        /* r2 <- contents of 'AdrData1 + 8' */
194
        ldr     r2, [r0, r1, lsl #2]
195
 
196
        ldr     r3, Data3
197
        cmp     r2, r3
198
        movne   r10, #170
199
        bne     testfail
200
 
201
 
202
/* Scaled Register offset pre-indexed */
203
        ldr     r4,  AdrData1
204
        mov     r5, #8
205
        /* r6 <- contents of 'AdrData1 + 4' */
206
        /* r4 <- AdrData1 + 4 */
207
        ldr     r6, [r4, r5, lsr #1]!
208
 
209
        ldr     r8,  Data2
210
        cmp     r6, r8
211
        movne   r10, #180
212
        bne     testfail
213
 
214
        ldr     r7,  AdrData1
215
        add     r7,  r7, #4
216
        cmp     r4, r7
217
        movne   r10, #190
218
        bne     testfail
219
 
220
 
221
/* Scaled Register offset post-indexed */
222
        ldr     r0,  AdrData8
223
        mov     r1, #1
224
        ldr     r2, [r0], -r1, ror #28
225
 
226
        ldr     r3, Data8
227
        cmp     r2, r3
228
        movne   r10, #200
229
        bne     testfail
230
 
231
        ldr     r4, AdrData8
232
        sub     r4, r4, #16
233
        cmp     r0, r4
234
        movne   r10, #210
235
        bne     testfail
236
 
237
 
238
/* Test unaligned word loads */
239
        ldr     r0, Data9
240
        mov     r1, #0x200
241
        str     r0, [r1]
242
 
243
        ldr     r2, [r1], #1
244
        ldr     r3, [r1], #1
245
        ldr     r4, [r1], #1
246
        ldr     r5, [r1], #1
247
 
248
        cmp     r2, r0
249
        movne   r10, #220
250
        bne     testfail
251
 
252
        mov     r6, r0, ror #8
253
        cmp     r6, r3
254
        movne   r10, #230
255
        bne     testfail
256
 
257
        mov     r7, r0, ror #16
258
        cmp     r7, r4
259
        movne   r10, #240
260
        bne     testfail
261
 
262
        mov     r8, r0, ror #24
263
        cmp     r8, r5
264
        movne   r10, #250
265
        bne     testfail
266
 
267
        b       testpass
268
 
269
 
270
testfail:
271
        ldr     r11, AdrTestStatus
272
        str     r10, [r11]
273
        b       testfail
274
 
275
testpass:
276
        ldr     r11, AdrTestStatus
277
        mov     r10, #17
278
        str     r10, [r11]
279
        b       testpass
280
 
281
 
282
/* Write 17 to this address to generate a Test Passed message */
283
AdrTestStatus:  .word  ADR_AMBER_TEST_STATUS
284
AdrData1:       .word  Data1
285
AdrData8:       .word  Data8
286
Data1:          .word  0x12345678
287
Data2:          .word  0x00000078
288
Data3:          .word  0x00000056
289
Data4:          .word  0x00000034
290
Data5:          .word  0x00000012
291
Data6:          .word  0xfecba987
292
Data7:          .word  0x78123456
293
Data8:          .word  0x34567812
294
Data9:          .word  0x33221100
295
 
296
/* ========================================================================= */
297
/* ========================================================================= */
298
 
299
 

powered by: WebSVN 2.1.0

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