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

assembler macro included in C macro

l.s.,

For delay purposes I need NOP's in an assembler macro, the code below doesn't do the trick. Thread 2267.htm doesn't help me either. A C macroloop, with e.g. DELAY(a); a = 10, slows the execution down too much. Can Anyone help me?

thanks, ***

#define DELAY(a) \
{ \
volatile unsigned b; \
for(b = 0; b < a; b++) \
{ \
} \
}

#define DELAYNOP \
{ \
#pragma asm \
NOP \
NOP \
NOP \
NOP \
NOP \
NOP \
NOP \
#pragma endasm \
}

Parents
  • "If you like, you can use assembly code to give you more control on timing issue."

    If you want it to work, you MUST use assembly code - because 'C' gives you absolutely NO control on timing issues!

    "You can use #pragma asm/endasm to embed to your C code."

    Better to write a specific assembler function, in an assembler source file.
    (by all means, use ASM/ENDASM to create the outline of your function - but then throw the 'C' away and just keep it in assembler).

Reply
  • "If you like, you can use assembly code to give you more control on timing issue."

    If you want it to work, you MUST use assembly code - because 'C' gives you absolutely NO control on timing issues!

    "You can use #pragma asm/endasm to embed to your C code."

    Better to write a specific assembler function, in an assembler source file.
    (by all means, use ASM/ENDASM to create the outline of your function - but then throw the 'C' away and just keep it in assembler).

Children
No data