X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=avr-asm-macros.S;h=afaf78ce1905b360abb9d9227bf4d1940f1fcdb5;hp=0fd325dfc168c6380fe941be23bb90b2971c1ecc;hb=e9e07569721b9e005d6b602e26a03e930e796577;hpb=e5a49deb52521f019e37779d6e9d81ec4f02aba4 diff --git a/avr-asm-macros.S b/avr-asm-macros.S index 0fd325d..afaf78c 100644 --- a/avr-asm-macros.S +++ b/avr-asm-macros.S @@ -1,7 +1,7 @@ /* avr-asm-macros.S */ /* This file is part of the AVR-Crypto-Lib. - Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,31 +17,34 @@ along with this program. If not, see . */ -/* +/* * File: avr-asm-macros.S * Author: Daniel Otte * Date: 2008-08-13 * License: GPLv3 or later * Description: some macros which are quite usefull - * + * */ - -#include +//#ifndef AVR_ASM_MACROS__S__ +//#define AVR_ASM_MACROS__S__ +.nolist +#include +.list /******************************************************************************* * MACRO SECTION * *******************************************************************************/ .macro push_ p1:req, p2:vararg push \p1 -.ifnb \p2 +.ifnb \p2 push_ \p2 .endif .endm .macro pop_ p1:req, p2:vararg pop \p1 -.ifnb \p2 +.ifnb \p2 pop_ \p2 .endif .endm @@ -50,13 +53,13 @@ push \from .if \to-\from push_range "(\from+1)",\to -.endif +.endif .endm .macro pop_range from:req, to:req pop \to .if \to-\from - pop_range \from,"(\to-1)" + pop_range \from,"(\to-1)" .endif .endm @@ -64,7 +67,7 @@ in r0, _SFR_IO_ADDR(SREG) in \reg1, _SFR_IO_ADDR(SPL) in \reg2, _SFR_IO_ADDR(SPH) - sbiw \reg1, \size + sbiw \reg1, \size cli out _SFR_IO_ADDR(SPH), \reg2 out _SFR_IO_ADDR(SREG), r0 @@ -75,7 +78,7 @@ in r0, _SFR_IO_ADDR(SREG) in \reg1, _SFR_IO_ADDR(SPL) in \reg2, _SFR_IO_ADDR(SPH) - adiw \reg1, \size + adiw \reg1, \size cli out _SFR_IO_ADDR(SPH), \reg2 out _SFR_IO_ADDR(SREG), r0 @@ -88,7 +91,7 @@ in \reg1, _SFR_IO_ADDR(SPL) in \reg2, _SFR_IO_ADDR(SPH) subi \reg1, lo8(\size) - sbci \reg2, hi8(\size) + sbci \reg2, hi8(\size) cli out _SFR_IO_ADDR(SPH), \reg2 out _SFR_IO_ADDR(SREG), r0 @@ -100,7 +103,7 @@ in \reg1, _SFR_IO_ADDR(SPL) in \reg2, _SFR_IO_ADDR(SPH) adiw \reg1, 63 - adiw \reg1, (\size-63) + adiw \reg1, (\size-63) cli out _SFR_IO_ADDR(SPH), \reg2 out _SFR_IO_ADDR(SREG), r0 @@ -113,7 +116,25 @@ in \reg2, _SFR_IO_ADDR(SPH) adiw \reg1, 63 adiw \reg1, 63 - adiw \reg1, (\size-63*2) + adiw \reg1, (\size-63*2) + cli + out _SFR_IO_ADDR(SPH), \reg2 + out _SFR_IO_ADDR(SREG), r0 + out _SFR_IO_ADDR(SPL), \reg1 +.endm + +.macro stack_free_large3 size:req, reg1=r30, reg2=r31 + in r0, _SFR_IO_ADDR(SREG) + in \reg1, _SFR_IO_ADDR(SPL) + in \reg2, _SFR_IO_ADDR(SPH) + push r16 + push r17 + ldi r16, lo8(\size) + ldi r17, hi8(\size) + add \reg1, r16 + adc \reg2, r17 + pop r17 + pop r16 cli out _SFR_IO_ADDR(SPH), \reg2 out _SFR_IO_ADDR(SREG), r0 @@ -126,4 +147,5 @@ *******************************************************************************/ +//#endif /* AVR_ASM_MACROS__S__ */