I used the source code of RTOS to save restore context but I get error when compiling.
#define BACKUP_CTX(sp)
asm volatile ("push r0 nt"
"in r0, __SREG__ nt"
"cli nt"
"push r0 nt"
"push r1 nt"
"clr r1 nt"
"push r2 nt"
"push r3 nt"
"push r4 nt"
"push r5 nt"
"push r6 nt"
"push r7 nt"
"push r8 nt"
"push r9 nt"
"push r10 nt"
"push r11 nt"
"push r12 nt"
"push r13 nt"
"push r14 nt"
"push r15 nt"
"push r16 nt"
"push r17 nt"
"push r18 nt"
"push r19 nt"
"push r20 nt"
"push r21 nt"
"push r22 nt"
"push r23 nt"
"push r24 nt"
"push r25 nt"
"push r26 nt"
"push r27 nt"
"push r28 nt"
"push r29 nt"
"push r30 nt"
"push r31 nt"
"lds r26, % 0 nt"
"lds r27, % 0 + 1 nt"
"in r0, 0x3d nt"
"st x+, r0 nt"
"in r0, 0x3e nt"
"st x+, r0 nt"
:: "r" (sp[0]));
#define RESTORE_CTX(sp)
asm volatile ( "lds r26, % 0 nt"
"lds r27, % 0 + 1 nt"
"ld r28, x+ nt"
"out __SP_L__, r28 nt"
"ld r29, x+ nt"
"out __SP_H__, r29 nt"
"pop r31 nt"
"pop r30 nt"
"pop r29 nt"
"pop r28 nt"
"pop r27 nt"
"pop r26 nt"
"pop r25 nt"
"pop r24 nt"
"pop r23 nt"
"pop r22 nt"
"pop r21 nt"
"pop r20 nt"
"pop r19 nt"
"pop r18 nt"
"pop r17 nt"
"pop r16 nt"
"pop r15 nt"
"pop r14 nt"
"pop r13 nt"
"pop r12 nt"
"pop r11 nt"
"pop r10 nt"
"pop r9 nt"
"pop r8 nt"
"pop r7 nt"
"pop r6 nt"
"pop r5 nt"
"pop r4 nt"
"pop r3 nt"
"pop r2 nt"
"pop r1 nt"
"pop r0 nt"
"out __SREG__, r0 nt"
"pop r0 nt"
:"=r" (sp[0]):);
but I get error :
bin/MicaZ/core/coroutines.o: In function `cr_run':
coroutines.c:(.text+0x72): undefined reference to `r24'
coroutines.c:(.text+0x76): undefined reference to `r24'
coroutines.c:(.text+0xd4): undefined reference to `r24'
coroutines.c:(.text+0xd8): undefined reference to `r24'
coroutines.c:(.text+0xf6): undefined reference to `r24'
bin/MicaZ/core/coroutines.o:coroutines.c:(.text+0xfa): more undefined references to `r24' follow
Do you have an idea?