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

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
Parents
  • 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


    hi

    The ARM C compilers support inline assembly language with the __asm specifier.

    you can use the following code for writing assembly code in C code

    void program_dma()

    {

    __asm
    {
    MCR p15, 0, Rd, c7, c0, 4
    }

    }
    you can use any number of instructions inside the brackets

    regards,
    Rajesh
Reply
  • 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


    hi

    The ARM C compilers support inline assembly language with the __asm specifier.

    you can use the following code for writing assembly code in C code

    void program_dma()

    {

    __asm
    {
    MCR p15, 0, Rd, c7, c0, 4
    }

    }
    you can use any number of instructions inside the brackets

    regards,
    Rajesh
Children
No data