]> git.cryptolib.org Git - avr-crypto-lib.git/blob - seed-asm.S
1c3c288962570c7131656bc42bdef67b5827900f
[avr-crypto-lib.git] / seed-asm.S
1 /**
2  * \file        seed-asm.S
3  * \author      Daniel Otte 
4  * \date        2007-06-1
5  * \brief       SEED parts in assembler for AVR
6  * \par License 
7  * GPL
8  * 
9  */
10 SPL = 0x3D
11 SPH = 0x3E
12 SREG = 0x3F
13
14
15 /*******************************************************************************
16
17         void changeendian32(uint32_t * a){
18                 *a = (*a & 0x000000FF) << 24 |
19                          (*a & 0x0000FF00) <<  8 |
20                          (*a & 0x00FF0000) >>  8 |
21                          (*a & 0xFF000000) >> 24;
22         }
23
24 */
25 /*
26 .global changeendian32
27 ; === change_endian32 ===
28 ; function that changes the endianess of a 32-bit word
29 ;  param1: the 32-bit word
30 ;       given in r25,r24,r23,22 (r25 is most significant)
31 ;  modifys: r21, r22
32 changeendian32:
33         movw r20,  r22 ; (r22,r23) --> (r20,r21)
34         mov r22, r25
35         mov r23, r24
36         mov r24, r21
37         mov r25, r20 
38         ret
39
40 */
41
42 /*******************************************************************************
43         uint32_t bigendian_sum32(uint32_t a, uint32_t b){
44                 changeendian32(&a);
45                 changeendian32(&b);
46                 a += b;
47                 changeendian32(&a);
48                 return a;
49         }
50 */
51
52 .global bigendian_sum32
53 ; === bigendian_sum32 ===
54 ; function that adds two 32-bit words in the bigendian way and returns the result
55 ;  param1: the first 32-bit word
56 ;       given in r25,r24,r23,22 (r25 is most significant for little endian)
57 ;  param2: the second 32-bit word
58 ;       given in r21,r20,r19,18 (r21 is most significant for little endian)
59 ;  modifys: 
60 bigendian_sum32:
61         add r25, r21
62         adc r24, r20
63         adc r23, r19
64         adc r22, r18
65         ret
66         
67 .global bigendian_sub32
68 ; === bigendian_sub32 ===
69 ; function that subtracts a 32-bit words from another in the bigendian way and returns the result
70 ;  param1: the minuend 32-bit word
71 ;       given in r25,r24,r23,22 (r25 is most significant for little endian)
72 ;  param2: the subtrahend 32-bit word
73 ;       given in r21,r20,r19,18 (r21 is most significant for little endian)
74 ;  modifys: 
75 bigendian_sub32:
76         sub r25, r21
77         sbc r24, r20
78         sbc r23, r19
79         sbc r22, r18
80         ret
81         
82
83
84
85
86
87
88
89
90