]> git.cryptolib.org Git - avr-crypto-lib.git/blob - seed-asm.S
insereated GPLv3 stub
[avr-crypto-lib.git] / seed-asm.S
1 /* seed-asm.S */
2 /*
3     This file is part of the Crypto-avr-lib/microcrypt-lib.
4     Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
5
6     This program is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 /**
20  * \file        seed-asm.S
21  * \author      Daniel Otte 
22  * \date        2007-06-1
23  * \brief       SEED parts in assembler for AVR
24  * \par License 
25  * GPL
26  * 
27  */
28 SPL = 0x3D
29 SPH = 0x3E
30 SREG = 0x3F
31
32
33 /*******************************************************************************
34
35         void changeendian32(uint32_t * a){
36                 *a = (*a & 0x000000FF) << 24 |
37                          (*a & 0x0000FF00) <<  8 |
38                          (*a & 0x00FF0000) >>  8 |
39                          (*a & 0xFF000000) >> 24;
40         }
41
42 */
43 /*
44 .global changeendian32
45 ; === change_endian32 ===
46 ; function that changes the endianess of a 32-bit word
47 ;  param1: the 32-bit word
48 ;       given in r25,r24,r23,22 (r25 is most significant)
49 ;  modifys: r21, r22
50 changeendian32:
51         movw r20,  r22 ; (r22,r23) --> (r20,r21)
52         mov r22, r25
53         mov r23, r24
54         mov r24, r21
55         mov r25, r20 
56         ret
57
58 */
59
60 /*******************************************************************************
61         uint32_t bigendian_sum32(uint32_t a, uint32_t b){
62                 changeendian32(&a);
63                 changeendian32(&b);
64                 a += b;
65                 changeendian32(&a);
66                 return a;
67         }
68 */
69
70 .global bigendian_sum32
71 ; === bigendian_sum32 ===
72 ; function that adds two 32-bit words in the bigendian way and returns the result
73 ;  param1: the first 32-bit word
74 ;       given in r25,r24,r23,22 (r25 is most significant for little endian)
75 ;  param2: the second 32-bit word
76 ;       given in r21,r20,r19,18 (r21 is most significant for little endian)
77 ;  modifys: 
78 bigendian_sum32:
79         add r25, r21
80         adc r24, r20
81         adc r23, r19
82         adc r22, r18
83         ret
84         
85 .global bigendian_sub32
86 ; === bigendian_sub32 ===
87 ; function that subtracts a 32-bit words from another in the bigendian way and returns the result
88 ;  param1: the minuend 32-bit word
89 ;       given in r25,r24,r23,22 (r25 is most significant for little endian)
90 ;  param2: the subtrahend 32-bit word
91 ;       given in r21,r20,r19,18 (r21 is most significant for little endian)
92 ;  modifys: 
93 bigendian_sub32:
94         sub r25, r21
95         sbc r24, r20
96         sbc r23, r19
97         sbc r22, r18
98         ret
99         
100
101
102
103
104
105
106
107
108