| Author |
Message |
yodathegreat
Joined: 23 Feb 2002 Posts: 56 Helped: 1
|
21 Aug 2004 16:53 c2076e |
|
|
|
|
Hi all,
How to convert this GCC code to ADS ARM C code ?.
best regards
#define portSAVE_CONTEXT() \
{ \
extern volatile void * volatile pxCurrentTCB; \
\
/* Push R0 as we are going to use the register. */ \
asm volatile ( "STMDB SP!, {R0}" ); \
\
/* Set R0 to point to the task stack pointer. */ \
asm volatile ( "STMDB SP,{SP}^" ); \
asm volatile ( "SUB SP, SP, #4" ); \
asm volatile ( "LDMIA SP!,{R0}" ); \
\
/* Push the return address onto the stack. */ \
asm volatile ( "STMDB R0!, {LR}" ); \
\
/* Now we have saved LR we can use it instead of R0. */ \
asm volatile ( "MOV LR, R0" ); \
\
/* Pop R0 so we can save it onto the system mode stack. */ \
asm volatile ( "LDMIA SP!, {R0}" ); \
\
/* Push all the system mode registers onto the task stack. */ \
asm volatile ( "STMDB LR,{R0-LR}^"); \
asm volatile ( "SUB LR, LR, #60" ); \
\
/* Push the SPSR onto the task stack. */ \
asm volatile ( "MRS R0, SPSR" ); \
asm volatile ( "STMDB LR!, {R0}" ); \
\
/* Store the new top of stack for the task. */ \
asm volatile ( "LDR R0, %0" : : "m" (pxCurrentTCB) ); \
asm volatile ( "STR LR, [R0]" ); \
}
|
|
| Back to top |
|
 |
dainis
Joined: 15 May 2001 Posts: 1451 Helped: 56
|
22 Aug 2004 19:28 convert c to arm |
|
|
|
|
ADS have this sintax of inline asm
#define SWI_SHOWREGS __asm {swi 0x0000004}
__asm { MRC P15, 0, i, c0, c0; }
|
|
| Back to top |
|
 |
yodathegreat
Joined: 23 Feb 2002 Posts: 56 Helped: 1
|
23 Aug 2004 0:22 __asm arm sp |
|
|
|
|
Hi Dainis,
i know the __asm.
but the problem is SP !! in inline asm ADS impossible to use SP register..
best regards
| dainis wrote: |
@DS have this sintax of inline asm
#define SWI_SHOWREGS __asm {swi 0x0000004}
__asm { MRC P15, 0, i, c0, c0; } |
|
|
| Back to top |
|
 |
Google AdSense

|
23 Aug 2004 0:22 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
dainis
Joined: 15 May 2001 Posts: 1451 Helped: 56
|
23 Aug 2004 7:25 __asm__ __volatile__ ldmia |
|
|
|
|
| yodathegreat wrote: |
Hi Dainis,
i know the __asm.
but the problem is SP !! in inline asm @DS impossible to use SP register..
best regards
| dainis wrote: |
@DS have this sintax of inline asm
#define SWI_SHOWREGS __asm {swi 0x0000004}
__asm { MRC P15, 0, i, c0, c0; } |
|
It is impossible change SP from inline asm ....
Maybe is possible insert code via __asm and define opcode as bianry data ???
C2076E: illegal write to SP
Example:
__asm{ mov sp,#0x4000; }
You must never try to change the Stack Pointer (sp=r13) using the inline assembler, because the
compiler requires full control of the stack for its operation, therefore writing to the SP is not
allowed. The compiler will stack/restore any working registers as required automatically.
|
|
| Back to top |
|
 |
artem
Joined: 22 May 2003 Posts: 1652 Helped: 91 Location: Turan
|
23 Aug 2004 10:07 __asm gcc arm |
|
|
|
|
| The problem here is that macro functionality is part of RTOS proting code where task switch is done . So SP is used legally . From other side the function can not be simply rewritten without modification as asm file and linked to c files as macro is expanded as inline file which means no stack usage at function call . and there is another reason - different register usage for fucntion calls due to different compilers .
|
|
| Back to top |
|
 |