]> git.cryptolib.org Git - avr-crypto-lib.git/blob - memxor.S
fixed small bug in MD5
[avr-crypto-lib.git] / memxor.S
1 /* memxor.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 /* 
21  * File:        memxor.S
22  * Author:      Daniel Otte
23  * Date:        2008-08-07
24  * License:     GPLv3 or later
25  * Description: memxor, XORing one block into another
26  * 
27  */
28  
29 #include <avr/io.h>
30 #include "avr-asm-macros.S"
31
32 /*
33  * void memxor(void* dest, const void* src, uint16_t n);
34  */
35  /*
36   * param dest is passed in r24:r25
37   * param src  is passed in r22:r23
38   * param n    is passed in r20:r21
39   */
40 .global memxor
41 memxor:
42         movw r30, r24
43         movw r26, r22
44         movw r24, r20
45         tst r24
46         brne 1f
47         tst r25
48         breq 2f
49 1:
50         ld r20, X+
51         ld r21, Z
52         eor r20, r21
53         st Z+, r20
54         sbiw r24, 1
55         brne 1b
56 2:
57         ret
58         
59         
60         
61         
62         
63         
64         
65         
66         
67         
68         
69         
70         
71