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

Subversion Repositories amber

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

Go to most recent revision | 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 add                                                   //
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
/* 3 + 1 */
48
        mov     r1, #3
49
        mov     r2, #1
50
        add     r3, r1, r2
51
        cmp     r3, #4
52
        movne   r10, #10
53
        bne     testfail
54
 
55
/* 0 + 0 */
56
        mov     r4, #0
57
        mov     r5, #0
58
        add     r6, r5, r4
59
        cmp     r6, #0
60
        movne   r10, #20
61
        bne     testfail
62
 
63
/* 0 + -1 */
64
        mov     r7, #0
65
        mov     r8, #-1
66
        add     r9, r7, r8
67
        cmp     r9, #-1
68
        movne   r10, #30
69
        bne     testfail
70
 
71
/* -1 + 0 */
72
        mov     r1, #-1
73
        mov     r2, #0
74
        add     r3, r1, r2
75
        cmp     r3, #-1
76
        movne   r10, #40
77
        bne     testfail
78
 
79
/* -1 + -1 */
80
        mov     r4, #-1
81
        mov     r5, #-1
82
        add     r6, r4, r5
83
        cmp     r6, #-2
84
        movne   r10, #50
85
        bne     testfail
86
 
87
/* -1 + -255 */
88
        mov     r7, #-1
89
        mov     r8, #-255
90
        add     r9, r7, r8
91
        cmp     r9, #-256
92
        movne   r10, #60
93
        bne     testfail
94
 
95
/* 1 + 0x7fffffff */
96
        ldr     r1, MaxPos
97
        mov     r2, #1
98
        adds    r3, r1, r2
99
        /* this should generate an overflow */
100
        /* so if the V flag is Clear then fail */
101
        bvc     testfail
102
        ldr     r0, MaxNeg
103
        cmp     r0, r3
104
        movne   r10, #70
105
        bne     testfail
106
        b       testpass
107
 
108
testfail:
109
        ldr     r11, AdrTestStatus
110
        str     r10, [r11]
111
        b       testfail
112
 
113
testpass:
114
        ldr     r11, AdrTestStatus
115
        mov     r10, #17
116
        str     r10, [r11]
117
        b       testpass
118
 
119
 
120
/* Write 17 to this address to generate a Test Passed message */
121
AdrTestStatus:  .word  ADR_AMBER_TEST_STATUS
122
MaxPos:         .word  0x7fffffff
123
MaxNeg:         .word  0x80000000
124
 
125
/* ========================================================================= */
126
/* ========================================================================= */
127
 
128
 

powered by: WebSVN 2.1.0

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