1
/* Copyright (c) 2006 Dmitry Xmelkov
4
Redistribution and use in source and binary forms, with or without
5
modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright
8
notice, this list of conditions and the following disclaimer.
9
* Redistributions in binary form must reproduce the above copyright
10
notice, this list of conditions and the following disclaimer in
11
the documentation and/or other materials provided with the
13
* Neither the name of the copyright holders nor the names of
14
contributors may be used to endorse or promote products derived
15
from this software without specific prior written permission.
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
POSSIBILITY OF SUCH DAMAGE. */
29
/* $Id: asmdef.h,v 1.1.2.1 2008/12/06 03:28:42 dmix Exp $ */
91
/* Macro REGNO set the symbol name 'name' to integer which is a 'reg'
92
number (0..31). If 'reg' is not a valid register, compilation error.
93
Valid regs are: r0..r31, R0..R31 and 0..31
95
.macro REGNO name, reg
99
.irp sym, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, \
100
r10,r11,r12,r13,r14,r15,r16,r17,r18,r19, \
101
r20,r21,r22,r23,r24,r25,r26,r27,r28,r29, \
106
.L__regno = .L__regno + 1
110
.irp sym, R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, \
111
R10,R11,R12,R13,R14,R15,R16,R17,R18,R19, \
112
R20,R21,R22,R23,R24,R25,R26,R27,R28,R29, \
117
.L__regno = .L__regno + 1
123
.if \reg == .L__regno
126
.L__regno = .L__regno + 1
131
.err ; Invalid dst arg of 'X_lpm' macro.
60
136
/* Macro 'X_movw' extends enhanced movw instruction for classic chips.
62
138
.macro X_movw dst,src
63
139
#if defined(__AVR_HAVE_MOVW__) && __AVR_HAVE_MOVW__
69
.irp reg, r0, r2, r4, r6, r8, \
70
r10,r12,r14,r16,r18, \
71
r20,r22,r24,r26,r28,r30
73
.L_movw_dst = .L_movw_n
76
.L_movw_src = .L_movw_n
78
.L_movw_n = .L_movw_n + 2
84
.L_movw_dst = .L_movw_n
86
.L_movw_n = .L_movw_n + 2
93
.L_movw_src = .L_movw_n
95
.L_movw_n = .L_movw_n + 2
98
.if (.L_movw_dst < 0) || (.L_movw_src < 0)
99
.err "Invalid arg of the X_movw macro."
102
mov .L_movw_dst + 1, .L_movw_src + 1
142
REGNO .L__movw_dst, \dst
147
.err ; Invalid dst arg in X_movw macro.
151
REGNO .L__movw_src, \src
156
.err ; Invalid src arg in X_movw macro.
159
mov .L__movw_dst, .L__movw_src
160
mov .L__movw_dst + 1, .L__movw_src + 1
106
164
/* Macro 'X_lpm' extends enhanced lpm instruction for classic chips.
125
183
.macro X_lpm dst=r0, src=Z
127
185
/* dst evaluation */
131
.irp reg, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, \
132
r10,r11,r12,r13,r14,r15,r16,r17,r18,r19, \
133
r20,r21,r22,r23,r24,r25,r26,r27,r28,r29, \
136
.L_lpm_dst = .L_lpm_n
138
.L_lpm_n = .L_lpm_n + 1
142
.irp reg, R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, \
143
R10,R11,R12,R13,R14,R15,R16,R17,R18,R19, \
144
R20,R21,R22,R23,R24,R25,R26,R27,R28,R29, \
147
.L_lpm_dst = .L_lpm_n
149
.L_lpm_n = .L_lpm_n + 1
156
.L_lpm_dst = .L_lpm_n
158
.L_lpm_n = .L_lpm_n + 1
163
.err "Invalid dst arg of 'X_lpm' macro."
186
REGNO .L__lpm_dst, \dst
188
.exitm ; do not multiply errors
166
191
/* src evaluation */
169
194
.irp reg, z,Z,z+,Z+
171
.L_lpm_src = .L_lpm_n
196
.L__lpm_src = .L__lpm_n
173
.L_lpm_n = .L_lpm_n + 1
198
.L__lpm_n = .L__lpm_n + 1
177
.err "Invalid src arg of 'X_lpm' macro."
201
.if (.L__lpm_src < 0)
202
.err ; Invalid src arg of 'X_lpm' macro.
180
205
/* instruction(s) */
185
210
#if defined(__AVR_HAVE_LPMX__) && __AVR_HAVE_LPMX__
193
.if (.L_lpm_dst >= 30)
194
.err "Registers 30 and 31 are inhibited as 'X_lpm *,Z+' dst."
218
.if (.L__lpm_dst >= 30)
219
.err ; Registers 30 and 31 are inhibited as 'X_lpm *,Z+' dst.
196
221
#if defined(__AVR_HAVE_LPMX__) && __AVR_HAVE_LPMX__
208
233
#endif /* !_ASMDEF_H */