Please give some example that will show how write and interface assembly function to C
Why?
We cannot add inline assembly for ARM cortex M0 , main.c(204): error: #1113: Inline assembler not permitted when generating Thumb code below piece of code give error because naked attribute is not in KEIL ARM
void NMI_Handler(void) __attribute__ (( naked )); void NMI_Handler(void) { /* Re-direct interrupt, get handler address from application vector table */ asm volatile("ldr r0, =0x1008"); asm volatile("ldr r0, [r0]"); asm volatile("mov pc, r0"); }
You can use the embedded assembly:
__asm void NMI_Handler(void) { /* Re-direct interrupt, get handler address from application vector table */ ldr r0, =0x1008 ldr r0, [r0] ; mov pc, r0 ; deprecated bx r0 }
Thanks Robert I have one more doubt
As per some document reference that I found on net the expected vector table generated by assembler is give below
__Vectors DCD __initial_sp ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; NMI Handler [...more vectors...]
00000000 LDR PC, =__initial_sp 00000004 LDR PC, =Reset_Handler 00000008 LDR PC, =NMI_Handler
but if we see actual code, it will be like
0x00000000 0268 LSLS r0,r5,#9 0x00000002 1000 ASRS r0,r0,#0 0x00000004 0169 LSLS r1,r5,#5 0x00000006 0000 MOVS r0,r0 0x00000008 0171 LSLS r1,r6,#5 0x0000000A 0000 MOVS r0,r0 0x0000000C 0173 LSLS r3,r6,#5 0x0000000E 0000 MOVS r0,r0
Any idea where will be the vector table?
Thanks
00000000 LDR PC, =__initial_sp ---> 4 Bytes 00000004 LDR PC, =Reset_Handler 00000008 LDR PC, =NMI_Handler ====================================== 0x00000000 0268 LSLS r0,r5,#9 ---> 2 Bytes 0x00000002 1000 ASRS r0,r0,#0 0x00000004 0169 LSLS r1,r5,#5 0x00000006 0000 MOVS r0,r0 0x00000008 0171 LSLS r1,r6,#5 0x0000000A 0000 MOVS r0,r0 0x0000000C 0173 LSLS r3,r6,#5 0x0000000E 0000 MOVS r0,r0
Again, the Vector Table contains addresses; not instructions - see your other thread about the Vector Table: http://www.keil.com/forum/19073/
What document, exactly?
Always give a link, so that people can check that it's a good document, and/or that you are correctly interpreting what it says.
Beware of just implicitly trusting everything you find on the net - always verify it against "official" documentation!