Am 04.03.20 um 13:28 schrieb Dylan McKay:> > * *The C/C++ function needs to be declared with either the calling > convention avr-interrupt or avr-non-blocking-interrupt.* Skipping > this step will cause regular ret instructions to be emitted for > return-from-subroutine, instead of the required reti for interrupt > handlers. ISRs also have stricter requirements on which registers > must not be clobbered after execution, which the backend will handle > properly by restoring all clobbered registers in the interrupt > handler epilogue > * *The symbol names of the ISR function handlers must match those > referred to in avr-libc/avr-libgcc/crt*. This is because the ISR > table is specified in assembly inside the GCC AVR CRT. The way it > works is that the external symbol references in the CRT object files > are declared with an exotic linkage type that causes the linker to > skip linking of the symbols if they are undefined references. If you > chose a custom ISR table in a custom CRT or runtime library, you > would be free to choose ISR names as you pleased. >Thank you for your explanation. But I suspect I didn't get it right. Can you please provide an example? Thanks
Here you go Wilhelm, https://github.com/dylanmckay/clang-avr-libc-interrupt-example On Thu, Mar 5, 2020 at 4:05 AM Wilhelm Meier <wilhelm.meier at hs-kl.de> wrote:> Am 04.03.20 um 13:28 schrieb Dylan McKay: > > > > > * *The C/C++ function needs to be declared with either the calling > > convention avr-interrupt or avr-non-blocking-interrupt.* Skipping > > this step will cause regular ret instructions to be emitted for > > return-from-subroutine, instead of the required reti for interrupt > > handlers. ISRs also have stricter requirements on which registers > > must not be clobbered after execution, which the backend will handle > > properly by restoring all clobbered registers in the interrupt > > handler epilogue > > * *The symbol names of the ISR function handlers must match those > > referred to in avr-libc/avr-libgcc/crt*. This is because the ISR > > table is specified in assembly inside the GCC AVR CRT. The way it > > works is that the external symbol references in the CRT object files > > are declared with an exotic linkage type that causes the linker to > > skip linking of the symbols if they are undefined references. If you > > chose a custom ISR table in a custom CRT or runtime library, you > > would be free to choose ISR names as you pleased. > > > Thank you for your explanation. But I suspect I didn't get it right. Can > you please provide an example? > > Thanks >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200311/ab94a19c/attachment.html>
Hi Dylan,
the following code
volatile uint8_t v1;
volatile uint8_t v2;
__attribute__((interrupt)) void __vector_21(void) {
v2 = v1;
}
produces in C mode:
00000092 <__vector_21>:
92: 80 91 61 00 lds r24, 0x0061 ; 0x800061 <v1>
96: 80 93 60 00 sts 0x0060, r24 ; 0x800060 <__data_end>
9a: 08 95 ret
and in C++ mode:
00000074 <_Z11__vector_21v>:
74: 80 91 60 00 lds r24, 0x0060 ; 0x800060 <__data_end>
78: 80 93 61 00 sts 0x0061, r24 ; 0x800061 <v2>
7c: 08 95 ret
So, in C++ mode it is not recognized as ISR due to name mangling.
Furthermore there are no register push/pos and no reti.
Whats wrong?
Thanks.
Am 11.03.20 um 08:13 schrieb Dylan McKay:> Here you go Wilhelm,
>
> https://github.com/dylanmckay/clang-avr-libc-interrupt-example
>
>
>
> On Thu, Mar 5, 2020 at 4:05 AM Wilhelm Meier <wilhelm.meier at hs-kl.de
> <mailto:wilhelm.meier at hs-kl.de>> wrote:
>
> Am 04.03.20 um 13:28 schrieb Dylan McKay:
>
> >
> > * *The C/C++ function needs to be declared with either the
calling
> > convention avr-interrupt or avr-non-blocking-interrupt.*
Skipping
> > this step will cause regular ret instructions to be emitted
for
> > return-from-subroutine, instead of the required reti for
interrupt
> > handlers. ISRs also have stricter requirements on which
registers
> > must not be clobbered after execution, which the backend will
> handle
> > properly by restoring all clobbered registers in the interrupt
> > handler epilogue
> > * *The symbol names of the ISR function handlers must match
those
> > referred to in avr-libc/avr-libgcc/crt*. This is because the
ISR
> > table is specified in assembly inside the GCC AVR CRT. The way
it
> > works is that the external symbol references in the CRT object
> files
> > are declared with an exotic linkage type that causes the
linker to
> > skip linking of the symbols if they are undefined references.
> If you
> > chose a custom ISR table in a custom CRT or runtime library,
you
> > would be free to choose ISR names as you pleased.
> >
> Thank you for your explanation. But I suspect I didn't get it
right. Can
> you please provide an example?
>
> Thanks
>