| 1 | 2 | olivier.gi | /*===========================================================================*/
 | 
      
         | 2 |  |  | /* Copyright (C) 2001 Authors                                                */
 | 
      
         | 3 |  |  | /*                                                                           */
 | 
      
         | 4 |  |  | /* This source file may be used and distributed without restriction provided */
 | 
      
         | 5 |  |  | /* that this copyright statement is not removed from the file and that any   */
 | 
      
         | 6 |  |  | /* derivative work contains the original copyright notice and the associated */
 | 
      
         | 7 |  |  | /* disclaimer.                                                               */
 | 
      
         | 8 |  |  | /*                                                                           */
 | 
      
         | 9 |  |  | /* This source file is free software; you can redistribute it and/or modify  */
 | 
      
         | 10 |  |  | /* it under the terms of the GNU Lesser General Public License as published  */
 | 
      
         | 11 |  |  | /* by the Free Software Foundation; either version 2.1 of the License, or    */
 | 
      
         | 12 |  |  | /* (at your option) any later version.                                       */
 | 
      
         | 13 |  |  | /*                                                                           */
 | 
      
         | 14 |  |  | /* This source is distributed in the hope that it will be useful, but WITHOUT*/
 | 
      
         | 15 |  |  | /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     */
 | 
      
         | 16 |  |  | /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public       */
 | 
      
         | 17 |  |  | /* License for more details.                                                 */
 | 
      
         | 18 |  |  | /*                                                                           */
 | 
      
         | 19 |  |  | /* You should have received a copy of the GNU Lesser General Public License  */
 | 
      
         | 20 |  |  | /* along with this source; if not, write to the Free Software Foundation,    */
 | 
      
         | 21 |  |  | /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA        */
 | 
      
         | 22 |  |  | /*                                                                           */
 | 
      
         | 23 |  |  | /*===========================================================================*/
 | 
      
         | 24 |  |  | /*                 TWO-OPERAND ARITHMETIC: DADD[.B] INSTRUCTION              */
 | 
      
         | 25 |  |  | /*---------------------------------------------------------------------------*/
 | 
      
         | 26 |  |  | /* Test the DADD[.B] instruction.                                            */
 | 
      
         | 27 | 18 | olivier.gi | /*                                                                           */
 | 
      
         | 28 |  |  | /* Author(s):                                                                */
 | 
      
         | 29 |  |  | /*             - Olivier Girard,    olgirard@gmail.com                       */
 | 
      
         | 30 |  |  | /*                                                                           */
 | 
      
         | 31 |  |  | /*---------------------------------------------------------------------------*/
 | 
      
         | 32 | 19 | olivier.gi | /* $Rev: 19 $                                                                */
 | 
      
         | 33 |  |  | /* $LastChangedBy: olivier.girard $                                          */
 | 
      
         | 34 |  |  | /* $LastChangedDate: 2009-08-04 23:47:15 +0200 (Tue, 04 Aug 2009) $          */
 | 
      
         | 35 | 2 | olivier.gi | /*===========================================================================*/
 | 
      
         | 36 |  |  |  
 | 
      
         | 37 |  |  |  
 | 
      
         | 38 |  |  | .global main
 | 
      
         | 39 |  |  |  
 | 
      
         | 40 |  |  | main:
 | 
      
         | 41 |  |  |         /* -------------- TEST INSTRUCTION IN WORD MODE ------------------- */
 | 
      
         | 42 |  |  |  
 | 
      
         | 43 |  |  |         # Test DADD without Carry bit set
 | 
      
         | 44 |  |  |         mov     #0x0000, r2
 | 
      
         | 45 |  |  |         mov     #0x0159, r4
 | 
      
         | 46 |  |  |         mov     #0x1078, r5
 | 
      
         | 47 |  |  |         dadd         r4, r5        ;# Add decimally r5+r4 (159+1078=1237)
 | 
      
         | 48 |  |  |  
 | 
      
         | 49 |  |  |         # Test DADD with Carry bit set
 | 
      
         | 50 |  |  |         mov     #0x0001, r2
 | 
      
         | 51 |  |  |         mov     #0x4999, r4
 | 
      
         | 52 |  |  |         mov     #0x2111, r6
 | 
      
         | 53 |  |  |         dadd         r4, r6        ;# Add decimally r6+r4 (4999+2111+C=7111)
 | 
      
         | 54 |  |  |  
 | 
      
         | 55 |  |  |  
 | 
      
         | 56 |  |  |         mov     #0x1000, r15
 | 
      
         | 57 |  |  |  
 | 
      
         | 58 |  |  |  
 | 
      
         | 59 |  |  |         /* -------------- TEST INSTRUCTION IN BYTE MODE ------------------- */
 | 
      
         | 60 |  |  |  
 | 
      
         | 61 |  |  |         # Test DADD.B without Carry bit set
 | 
      
         | 62 |  |  |         mov     #0x0000, r2
 | 
      
         | 63 |  |  |         mov     #0x0159, r4
 | 
      
         | 64 |  |  |         mov     #0x1078, r5
 | 
      
         | 65 |  |  |         dadd.b       r4, r5        ;# Add decimally r5+r4 (59+78=37)
 | 
      
         | 66 |  |  |  
 | 
      
         | 67 |  |  |         # Test DADD.B with Carry bit set
 | 
      
         | 68 |  |  |         mov     #0x0001, r2
 | 
      
         | 69 |  |  |         mov     #0x3149, r4
 | 
      
         | 70 |  |  |         mov     #0x5621, r6
 | 
      
         | 71 |  |  |         dadd.b       r4, r6        ;# Add decimally r6+r4 (49+21+C=71)
 | 
      
         | 72 |  |  |  
 | 
      
         | 73 |  |  |  
 | 
      
         | 74 |  |  |         mov     #0x2000, r15
 | 
      
         | 75 |  |  |  
 | 
      
         | 76 |  |  |  
 | 
      
         | 77 |  |  |         /* ------------------ TEST FLAGS IN WORD MODE ---------------------- */
 | 
      
         | 78 |  |  |  
 | 
      
         | 79 |  |  |         mov     #0x0000, r2        ;# V=0, N=0, Z=0, C=0
 | 
      
         | 80 |  |  |         mov     #0x7995, r4        ;#
 | 
      
         | 81 |  |  |         mov     #0x0004, r5        ;#
 | 
      
         | 82 |  |  |         dadd         r4, r5        ;# Add decimally r5+r4 (7995+0004=7999)
 | 
      
         | 83 |  |  |         mov     #0x3000, r15
 | 
      
         | 84 |  |  |  
 | 
      
         | 85 |  |  |         mov     #0x0000, r2        ;# V=0, N=0, Z=0, C=1
 | 
      
         | 86 |  |  |         mov     #0x7995, r4        ;#
 | 
      
         | 87 |  |  |         mov     #0x2007, r5        ;#
 | 
      
         | 88 |  |  |         dadd         r4, r5        ;# Add decimally r5+r4 (7995+2007=2)
 | 
      
         | 89 |  |  |         mov     #0x3001, r15
 | 
      
         | 90 |  |  |  
 | 
      
         | 91 |  |  |         mov     #0x0000, r2        ;# V=0, N=0, Z=1, C=1
 | 
      
         | 92 |  |  |         mov     #0x7995, r4        ;#
 | 
      
         | 93 |  |  |         mov     #0x2005, r5        ;#
 | 
      
         | 94 |  |  |         dadd         r4, r5        ;# Add decimally r5+r4 (7995+2005=0)
 | 
      
         | 95 |  |  |         mov     #0x3002, r15
 | 
      
         | 96 |  |  |  
 | 
      
         | 97 |  |  |         mov     #0x0000, r2        ;# V=1, N=1, Z=0, C=0
 | 
      
         | 98 |  |  |         mov     #0x7995, r4        ;#
 | 
      
         | 99 |  |  |         mov     #0x0007, r5        ;#
 | 
      
         | 100 |  |  |         dadd         r4, r5        ;# Add decimally r5+r4 (7995+7=8002)
 | 
      
         | 101 |  |  |         mov     #0x3003, r15
 | 
      
         | 102 |  |  |  
 | 
      
         | 103 |  |  |  
 | 
      
         | 104 |  |  |         /* ------------------ TEST FLAGS IN BYTE MODE --------------------- */
 | 
      
         | 105 |  |  |  
 | 
      
         | 106 |  |  |         mov     #0x0000, r2        ;# V=0, N=0, Z=0, C=0
 | 
      
         | 107 |  |  |         mov     #0x4675, r4        ;#
 | 
      
         | 108 |  |  |         mov     #0x3104, r5        ;#
 | 
      
         | 109 |  |  |         dadd.b       r4, r5        ;# Add decimally r5+r4 (75+4=79)
 | 
      
         | 110 |  |  |         mov     #0x4000, r15
 | 
      
         | 111 |  |  |  
 | 
      
         | 112 |  |  |         mov     #0x0000, r2        ;# V=0, N=0, Z=0, C=1
 | 
      
         | 113 |  |  |         mov     #0x4775, r4        ;#
 | 
      
         | 114 |  |  |         mov     #0x3027, r5        ;#
 | 
      
         | 115 |  |  |         dadd.b       r4, r5        ;# Add decimally r5+r4 (75+27=2)
 | 
      
         | 116 |  |  |         mov     #0x4001, r15
 | 
      
         | 117 |  |  |  
 | 
      
         | 118 |  |  |         mov     #0x0000, r2        ;# V=0, N=0, Z=1, C=1
 | 
      
         | 119 |  |  |         mov     #0x4775, r4        ;#
 | 
      
         | 120 |  |  |         mov     #0x3125, r5        ;#
 | 
      
         | 121 |  |  |         dadd.b       r4, r5        ;# Add decimally r5+r4 (75+25=0)
 | 
      
         | 122 |  |  |         mov     #0x4002, r15
 | 
      
         | 123 |  |  |  
 | 
      
         | 124 |  |  |         mov     #0x0000, r2        ;# V=1, N=1, Z=0, C=0
 | 
      
         | 125 |  |  |         mov     #0x4675, r4        ;#
 | 
      
         | 126 |  |  |         mov     #0x3207, r5        ;#
 | 
      
         | 127 |  |  |         dadd.b       r4, r5        ;# Add decimally r5+r4 (75+7=82)
 | 
      
         | 128 |  |  |         mov     #0x4003, r15
 | 
      
         | 129 |  |  |  
 | 
      
         | 130 |  |  |  
 | 
      
         | 131 |  |  |         /* ----------------------         END OF TEST        --------------- */
 | 
      
         | 132 |  |  |         mov      #0x5000, r15
 | 
      
         | 133 |  |  | end_of_test:
 | 
      
         | 134 |  |  |         nop
 | 
      
         | 135 |  |  |         br #0xffff
 | 
      
         | 136 |  |  |  
 | 
      
         | 137 |  |  |  
 | 
      
         | 138 |  |  |         /* ----------------------         INTERRUPT VECTORS  --------------- */
 | 
      
         | 139 |  |  |  
 | 
      
         | 140 |  |  | .section .vectors, "a"
 | 
      
         | 141 |  |  | .word end_of_test  ; Interrupt  0 (lowest priority)    
 | 
      
         | 142 |  |  | .word end_of_test  ; Interrupt  1                      
 | 
      
         | 143 |  |  | .word end_of_test  ; Interrupt  2                      
 | 
      
         | 144 |  |  | .word end_of_test  ; Interrupt  3                      
 | 
      
         | 145 |  |  | .word end_of_test  ; Interrupt  4                      
 | 
      
         | 146 |  |  | .word end_of_test  ; Interrupt  5                      
 | 
      
         | 147 |  |  | .word end_of_test  ; Interrupt  6                      
 | 
      
         | 148 |  |  | .word end_of_test  ; Interrupt  7                      
 | 
      
         | 149 |  |  | .word end_of_test  ; Interrupt  8                      
 | 
      
         | 150 |  |  | .word end_of_test  ; Interrupt  9                      
 | 
      
         | 151 |  |  | .word end_of_test  ; Interrupt 10                      Watchdog timer
 | 
      
         | 152 |  |  | .word end_of_test  ; Interrupt 11                      
 | 
      
         | 153 |  |  | .word end_of_test  ; Interrupt 12                      
 | 
      
         | 154 |  |  | .word end_of_test  ; Interrupt 13                      
 | 
      
         | 155 |  |  | .word end_of_test  ; Interrupt 14                      NMI
 | 
      
         | 156 |  |  | .word main         ; Interrupt 15 (highest priority)   RESET
 |