3 This file is part of the Crypto-avr-lib/microcrypt-lib.
4 Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
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.
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.
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/>.
21 * File: avr-asm-macros.S
24 * License: GPLv3 or later
25 * Description: some macros which are quite usefull
31 /*******************************************************************************
33 *******************************************************************************/
35 .macro push_ p1:req, p2:vararg
42 .macro pop_ p1:req, p2:vararg
49 .macro push_range from:req, to:req
52 push_range "(\from+1)",\to
56 .macro pop_range from:req, to:req
59 pop_range \from,"(\to-1)"
63 .macro stack_alloc size:req, reg1=r30, reg2=r31
64 in r0, _SFR_IO_ADDR(SREG)
65 in \reg1, _SFR_IO_ADDR(SPL)
66 in \reg2, _SFR_IO_ADDR(SPH)
69 out _SFR_IO_ADDR(SPH), \reg2
70 out _SFR_IO_ADDR(SREG), r0
71 out _SFR_IO_ADDR(SPL), \reg1
74 .macro stack_free size:req, reg1=r30, reg2=r31
75 in r0, _SFR_IO_ADDR(SREG)
76 in \reg1, _SFR_IO_ADDR(SPL)
77 in \reg2, _SFR_IO_ADDR(SPH)
80 out _SFR_IO_ADDR(SPH), \reg2
81 out _SFR_IO_ADDR(SREG), r0
82 out _SFR_IO_ADDR(SPL), \reg1
85 /*******************************************************************************
86 * END of MACRO SECTION *
87 *******************************************************************************/