Equivalent for NOP in C for Embedded?
There's an intrinsic nop
in most compilers, Keil should have this as well - try __nop()
See - http://www.keil.com/support/man/docs/armccref/armccref_CJABCDAD.htm
Intrinsic functions are usually safer than directly adding assembly code for compatibility reasons.
Does this vary with the embedded controller that I use?
Yes. Inline assembly is not part of the C standard (yet), it varies from compiler to compiler and sometimes even between different target architectures of the same compiler. See Is inline asm part of the ANSI C standard? for more information.
For example, for the C51
Keil compiler, the syntax for inline assembly is
...
#pragma asm
NOP
#pragma endasm
...
while for ARM
, the syntax is something like
...
__asm {
NOP
}
...
You will need to check the manual for the actual compiler you are using.
For some of the more common opcodes, some compilers provide so-called intrinsics - these can be called like a C function but essentially insert assembly code, like _nop_ ()
.