I am trying to run some assembly in C. But I keep getting this error. I am not sure why. I know it is not good practice to mix assembly and C but I am new and would like to convert all of the C to assembly if possible. I don't think I need the attribute but I was trying to do things to remedy this error. The error comes from this line:
__asm(" LDR r1, %[OS_curr] \n"
::"r" (OS_curr)
);
I am running this on a MSP432 microcontroller ARM compiler. Thank you.
void PendSV_Handler() __attribute__((naked));
void PendSV_Handler(void)
{
OSThread *volatile OS_currcopy;
OS_currcopy = OS_curr;
void *sp;
__disable_interrupt();
__asm(" LDR r1, %[OS_curr] \n"
::"r" (OS_curr)
);
if(OS_curr != (OSThread *) 0){
asm(" PUSH {r4-r11}");
OS_curr -> sp = sp;
}
sp = OS_next -> sp;
OS_curr = OS_next;
asm(" POP {r4-r11}");
__enable_interrupt();
}
.global OS_curr
.global OS_next
.global PendSV_HandlerAsm
.curradd: .word OS_curr
.currnext: .word OS_next
PendSV_HandlerAsm:
CPSID i
;if(OS_curr != (OSThread *)0)
LDR r1, .curradd
LDR r1, [r0]
CBZ r1, PendSV_restore
;Push r4 - r11
PUSH {r4-r11}
LDR r1, .curradd
LDR r1, [r1]
;OS_curr -> sp = sp;
STR sp, [r1]
PendSV_restore:
;sp=OS_next -> sp;
LDR r1, .currnext
LDR r1, [r0]
LDR r1, [r0]
STR sp, [r13]
;OS_curr = OS_next;
LDR r1, .currnext
LDR r1, [r1]
LDR r2, .curradd
LDR r1, [r1]
;Pop r4-r11
POP {r4-r11}
;__enable_interrupts();
CPSIE i
;return to next thread
BX r14