4
#ifndef __AVR_HAVE_MOVW__
5
# if defined(__AVR_ENHANCED__) && __AVR_ENHANCED__
6
# define __AVR_HAVE_MOVW__ 1
10
#ifndef __AVR_HAVE_LPMX__
11
# if defined(__AVR_ENHANCED__) && __AVR_ENHANCED__
12
# define __AVR_HAVE_LPMX__ 1
16
/* Historicaly, the _U() was intended to concatinate '_' prefix.
17
Let us save it, as one is usefull to find externals quickly. */
27
#define SPL_IO_ADDR 0x3D
28
#define SPH_IO_ADDR 0x3E
32
.err "FUNCTION is defined already"
36
.section FUNC_SEGNAME, "ax", @progbits
40
.type _U(\name), "function"
42
.err ".LEND is defined already"
44
.size _U(\name), .LEND - .
46
#define FUNCTION FUNCTION /* for CPP conditional expressions */
60
/* Macro 'X_movw' extends enhanced movw instruction for classic chips.
63
#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
106
/* Macro 'X_lpm' extends enhanced lpm instruction for classic chips.
110
reg is 0..31, r0..r31 or R0..R31
111
dst is z, Z, z+ or Z+
112
It is possible to omit both arguments.
114
Possible results for classic chips:
118
lpm / mov Rd,r0 / adiw ZL,1
120
For enhanced chips it is one instruction always.
122
ATTENTION: unlike enhanced chips SREG (S,V,N,Z,C) flags are
123
changed in case of 'Z+' dst. R0 is scratch.
125
.macro X_lpm dst=r0, src=Z
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."
171
.L_lpm_src = .L_lpm_n
173
.L_lpm_n = .L_lpm_n + 1
177
.err "Invalid src arg of 'X_lpm' macro."
185
#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."
196
#if defined(__AVR_HAVE_LPMX__) && __AVR_HAVE_LPMX__
208
#endif /* !_ASMDEF_H */