Arm Community
Site
Search
User
Site
Search
User
Support forums
Architectures and Processors forum
Writing ARM application containing both C code and assemply code
Jump...
Cancel
State
Accepted Answer
+1
person also asked this
people also asked this
Locked
Locked
Replies
10 replies
Subscribers
350 subscribers
Views
8427 views
Users
0 members are here
Arm7
Address
compiler
program
Interrupt
Options
Share
More actions
Cancel
Related
How was your experience today?
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
Writing ARM application containing both C code and assemply code
Pavan Kumar
over 12 years ago
Note: This was originally posted on 6th September 2007 at
http://forums.arm.com
Hi I need to put one ARM instruction in ARM application written in C.
Basically my application looks like
void main(void)
{
................
................
enable_IRQ();
program_dma(); /* programs DMA with st address, dest addr, xfer length etc and enables DMA*/
/* Here I want to put a ARM instruction(assembly) */
..............
}
Extra information:
After enabling DMA, I want to execute WaitForInterrupt instruction by doing
MCR p15, 0, Rd, c7, c0, 4
Since this is C code I cant directly put that instruction( I guess).
Can you tell me how can I put that MCR instruction in my C code
Top replies
Simon Craske
over 12 years ago
+1
verified
Note: This was originally posted on 10th September 2007 at http://forums.arm.com Pavan, ARMCC also provides "embedded" assembler which allows simple creation of assembler functions within C source code;...
Parents
+1
Simon Craske
over 12 years ago
Note: This was originally posted on 10th September 2007 at
http://forums.arm.com
Pavan,
ARMCC also provides "embedded" assembler which allows simple creation of assembler functions within C source code; for example, your code could become:
__asm void WFI(void)
{
MCR p15,0,r0,c7,c0,4; // wait-for-interrupt
BX lr; // return from function
}
which could then be called from other C code via the standard C function method, e.g. WFI();.
The use of linker inlining would allow the linker to replace the call to your WFI() function with the MCR itself, producing code similar to that of the inline assembler.
hth
s.
Cancel
Vote up
+1
Vote down
Cancel
Reply
+1
Simon Craske
over 12 years ago
Note: This was originally posted on 10th September 2007 at
http://forums.arm.com
Pavan,
ARMCC also provides "embedded" assembler which allows simple creation of assembler functions within C source code; for example, your code could become:
__asm void WFI(void)
{
MCR p15,0,r0,c7,c0,4; // wait-for-interrupt
BX lr; // return from function
}
which could then be called from other C code via the standard C function method, e.g. WFI();.
The use of linker inlining would allow the linker to replace the call to your WFI() function with the MCR itself, producing code similar to that of the inline assembler.
hth
s.
Cancel
Vote up
+1
Vote down
Cancel
Children
No data