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

Subversion Repositories amber

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

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 35 csantifort
#include "amber_macros.h"
43 2 csantifort
 
44
        .section .text
45
        .globl  main
46
main:
47
 
48
/* 3 + 1 */
49
        mov     r1, #3
50
        mov     r2, #1
51
        add     r3, r1, r2
52 35 csantifort
        expect  r3, 4, __LINE__
53 2 csantifort
 
54
/* 0 + 0 */
55
        mov     r4, #0
56
        mov     r5, #0
57
        add     r6, r5, r4
58 35 csantifort
        expect  r6, 0, __LINE__
59 2 csantifort
 
60
/* 0 + -1 */
61
        mov     r7, #0
62
        mov     r8, #-1
63
        add     r9, r7, r8
64 35 csantifort
        expect  r9, -1, __LINE__
65 2 csantifort
 
66
/* -1 + 0 */
67
        mov     r1, #-1
68
        mov     r2, #0
69
        add     r3, r1, r2
70 35 csantifort
        expect  r3, -1, __LINE__
71 2 csantifort
 
72
/* -1 + -1 */
73
        mov     r4, #-1
74
        mov     r5, #-1
75
        add     r6, r4, r5
76 35 csantifort
        expect  r6, -2, __LINE__
77 2 csantifort
 
78
/* -1 + -255 */
79
        mov     r7, #-1
80
        mov     r8, #-255
81
        add     r9, r7, r8
82 35 csantifort
        expect  r9, -256, __LINE__
83 2 csantifort
 
84
/* 1 + 0x7fffffff */
85
        ldr     r1, MaxPos
86
        mov     r2, #1
87
        adds    r3, r1, r2
88
        /* this should generate an overflow */
89
        /* so if the V flag is Clear then fail */
90
        bvc     testfail
91
        ldr     r0, MaxNeg
92 35 csantifort
        compare r0, r3, __LINE__
93
 
94 2 csantifort
        b       testpass
95
 
96
testfail:
97
        ldr     r11, AdrTestStatus
98
        str     r10, [r11]
99
        b       testfail
100
 
101
testpass:
102
        ldr     r11, AdrTestStatus
103
        mov     r10, #17
104
        str     r10, [r11]
105
        b       testpass
106
 
107
 
108
/* Write 17 to this address to generate a Test Passed message */
109
AdrTestStatus:  .word  ADR_AMBER_TEST_STATUS
110
MaxPos:         .word  0x7fffffff
111
MaxNeg:         .word  0x80000000
112
 
113
/* ========================================================================= */
114
/* ========================================================================= */
115
 
116
 

powered by: WebSVN 2.1.0

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