1 /* Copyright (C) 2019-2024 Free Software Foundation, Inc.
3 This file is part of LIBF7, which is part of GCC.
5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 3, or (at your option) any later
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
29 /*****************************************************************/
30 /* Stuff for Assembler-only */
31 /*****************************************************************/
33 #if defined (__AVR_TINY__)
34 #define __tmp_reg__ 16
35 #define __zero_reg__ 17
38 #define __zero_reg__ 1
43 #if defined (__AVR_HAVE_SPH__)
47 #if !defined ASM_DEFS_HAVE_DEFUN
63 #endif /* HAVE_DEFUN */
66 #if defined (__AVR_HAVE_JMP_CALL__)
74 #if defined (__AVR_HAVE_EIJMP_EICALL__)
89 Factor out support of MOVW. Usage is like
93 to move R25:R24 to R31:R30, i.e. plain register numbers
94 are required and no register prefix 'R'.
97 #if defined (__AVR_HAVE_MOVW__)
105 r0
, r1
, r2
, r3
, r4
, r5
, r6
, r7
, r8
, r9
, \
106 r10
, r11
, r12
, r13
, r14
, r15
, r16
, r17
, r18
, r19
, \
107 r20
, r21
, r22
, r23
, r24
, r25
, r26
, r27
, r28
, r29
, \
115 ..regno
= ..regno
+ 1
121 R0
, R1
, R2
, R3
, R4
, R5
, R6
, R7
, R8
, R9
, \
122 R10
, R11
, R12
, R13
, R14
, R15
, R16
, R17
, R18
, R19
, \
123 R20
, R21
, R22
, R23
, R24
, R25
, R26
, R27
, R28
, R29
, \
131 ..regno
= ..regno
+ 1
137 X
, x
, XL
, xl
, Xl
, xL
, x
, x
, \
138 Y
, y
, YL
, yl
, Yl
, yL
, y
, y
, \
139 Z
, z
, ZL
, zl
, Zl
, zL
, z
, z
141 ..dst
= 2 * (..regno
/ 8) + 26
144 ..src
= 2 * (..regno
/ 8) + 26
146 ..regno
= ..regno
+ 1
155 #if !defined (__AVR_TINY__)
157 Convenience macro for easy use of __prologue_saves__ from libgcc.
158 Push the N_PUSHED callee-saved registers Y, R17, R16, R15, ...
159 with 0 <= N_PUSHED <= 18. The frame pointer (Y) is set up according
160 to a frame size of N_FRAME. Clobbers TMP_REG.
161 For the code of __prologue_saves__ from libgcc see
162 http://gcc.gnu.org/viewcvs/gcc/trunk/libgcc/config/avr/lib1funcs.S?revision=267494&view=markup#l2159
165 .macro do_prologue_saves n_pushed n_frame
=0
166 ldi r26
, lo8(\n_frame
)
167 ldi r27
, hi8(\n_frame
)
168 ldi r30
, lo8(gs(.L_prologue_saves
.\@
))
169 ldi r31
, hi8(gs(.L_prologue_saves
.\@
))
170 XJMP __prologue_saves__
+ ((18 - (\n_pushed
)) * 2)
171 .L_prologue_saves
.\@
:
175 Convenience macro for easy use of __epilogue_restores__ from libgcc.
176 Undo the effect of __prologue_saves__. Clobbers TMP_REG.
177 For the code of __epilogue_restores__ from libgcc see
178 http://gcc.gnu.org/viewcvs/gcc/trunk/libgcc/config/avr/lib1funcs.S?revision=267494&view=markup#l2216
181 .macro do_epilogue_restores n_pushed n_frame
=0
183 #ifdef __AVR_HAVE_SPH__
186 subi r28
, lo8(-\n_frame
)
187 sbci r29
, hi8(-\n_frame
)
194 subi r28
, lo8(-\n_frame
)
196 #endif /* HAVE SPH */
198 XJMP __epilogue_restores__
+ ((18 - (\n_pushed
)) * 2)
201 #endif /* AVR_TINY */
203 #else /* Assembler */
204 /*****************************************************************/
205 /* Space for C/C++ only Stuff */
206 /*****************************************************************/
207 #endif /* Assembler */
209 /*****************************************************************/
210 /* Space for Generic Stuff (Assembler, C, C++) */
211 /*****************************************************************/
213 #ifdef __AVR_PM_BASE_ADDRESS__
215 Devices with a linear address space: Flash memory is seen in the
216 RAM address space at an offset of __AVR_PM_BASE_ADDRESS__ and can
217 be accessed by LD*. This is the case for devices like ATtiny40
218 (avrtiny) or ATtiny1616 and ATmega4808 (avrxmega3). The default
219 linker script locates .rodata in the .text output section and
220 at the required offset.
222 #define RODATA_SECTION .rodata.asm
225 #else /* PM_BASE_ADDRESS */
227 No linear address space. As .rodata is located in RAM, we have to
228 use .progmem.data (located in flash) and LPM to read the data.
229 This will also work for devices from avrxmega3.
231 #define RODATA_SECTION .progmem.data.asm
234 #endif /* PM_BASE_ADDRESS */
236 #endif /* target AVR */
237 #endif /* ASM_DEFS_H */