electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

Convert GCC ARM to ADS ARM C source.


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> Convert GCC ARM to ADS ARM C source.
Author Message
yodathegreat



Joined: 23 Feb 2002
Posts: 56
Helped: 1


Post21 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


Post22 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


Post23 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
Google Adsense




Post23 Aug 2004 0:22   

Ads




Back to top
dainis



Joined: 15 May 2001
Posts: 1451
Helped: 56


Post23 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


Post23 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
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> Convert GCC ARM to ADS ARM C source.
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
GCC-ARM-COFF (9)
Troubleshoot arm-elf-gcc compiler (2)
ARM IDE that uses GCC (4)
GNU ARM GCC With Code::Blocks (1)
Assembly Language output from arm-elf-gcc (2)
how to use gcc to compile C files for ARM? (1)
how to use gcc tool chain for arm in linux (5)
Difference b/w ARM METRO and ARM ADVANTAGE std cell lib? (2)
Hi Can any one recomend ARM 7 or ARM 9 SBC up to 300$ (4)
ARM board, ARM Bios, JTAG, Wiggler, uClinux .... (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS