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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [teq.S] - Blame information for rev 87

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 82 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 with carry                                        //
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
// Test "Strange issue with r12 after TEQLSP"
42
// Tests for bug where testlsp command would switch the core
43
// from supervisor into FIRQ mode if it were executed. However the condition is not
44 87 csantifort
// met so it is not executed. The bug is the next instrument works in FIRQ mode anyway.
45 82 csantifort
// This was caused because the mode bits used in the ececute stage were not conditional on the
46
// teq instrumention being executed.
47
 
48 87 csantifort
// Also tests correct setting of carry flag when second operand is a constant
49
 
50
 
51 82 csantifort
#include "amber_registers.h"
52
#include "amber_macros.h"
53
 
54
        .section .text
55
        .globl  main
56
main:
57
 
58
        // Test "Strange issue with r12 after TEQLSP"
59
        mov     r1,  #0x0
60
        mov     r2,  #0x1
61
        mov     r6,  #10
62
        mov     r12, #100
63
        nop
64
 
65
        // this next instrument does not get executed because 'ls' condition is false
66
        teqlsp  r1,  r2 // r1 XOR r2 = 0x1 -> sets the mode bits of the PC to 1
67
        mov     r12, r6 // user r12 or FIRQ r12 ?
68
 
69
        cmp     r12, r6 // error if user mode r12 was not updated with new value
70
        bne     testfail
71
 
72 87 csantifort
        // check the carry flag
73
        // When a flexible second operand constant is used with the instructions MOVS, MVNS, ANDS, ORRS, ORNS, EORS, BICS,
74
        // TEQ or TST, the carry flag is updated to bit[31] of the constant, if the constant is greater than 255
75
        // and can be produced by shifting an 8-bit value. These instructions do not affect the carry flag if
76
        // Operand2 is any other constant.
77
        teq     r4, #0x80000000
78
        bcc     testfail
79
 
80
        // keeps carry flag the same
81
        teq     r4, #0x00000000
82
        bcc     testfail
83
 
84
        // sets the carry flag back to zero
85
        teq     r4, #0x40000000
86
        bcs     testfail
87
 
88
        // set the carry flag and verify that teq with register for operand 2 does not clear it
89
        teq     r4, #0x80000000
90
        mov     r4, #0
91
        mov     r5, #0x40000000
92
        teq     r4, r5
93
        bcc     testfail
94
 
95 82 csantifort
        b       testpass
96
 
97
testfail:
98
        ldr     r11, AdrTestStatus
99
        str     r10, [r11]
100
        b       testfail
101
 
102
testpass:
103
        ldr     r11, AdrTestStatus
104
        mov     r10, #17
105
        str     r10, [r11]
106
        b       testpass
107
 
108
 
109
AdrTestStatus:  .word  ADR_AMBER_TEST_STATUS
110
 

powered by: WebSVN 2.1.0

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