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

What's the C equivalent of NOP

I will replace the assembler instruction "nop" by a C instruction.
How do I made ?

Parents
  • First, this solution attempts to use generic C but will be compiler dependent. I'm not very optimistic it would work:

    void foo( void )
    {
    ; /* A semicolon without an instruction may produce a NOP. */
    }

    Second, this will work in Keil C51

    void foo( void )
    {
    #pragma asm
    NOP ; Use the ASM directive to insert assembly within C code.
    #pragma endasm
    }

    Hope this helps.

    Mark Shelton
    Remove "nospam" from my e-mail address for direct replies.

Reply
  • First, this solution attempts to use generic C but will be compiler dependent. I'm not very optimistic it would work:

    void foo( void )
    {
    ; /* A semicolon without an instruction may produce a NOP. */
    }

    Second, this will work in Keil C51

    void foo( void )
    {
    #pragma asm
    NOP ; Use the ASM directive to insert assembly within C code.
    #pragma endasm
    }

    Hope this helps.

    Mark Shelton
    Remove "nospam" from my e-mail address for direct replies.

Children
No data