If I have the following line of code in an Arduino based project:
Will this have exactly the same effect as nop in PIC12F675? Does it matter that the PIC in question and the Arduino may operate at different speeds?
So a 20MHz clock will give you delay of 200 ns (4/20 MHz).
The AVR used in Arduino OTOH delivers 1 MIPS/MHz, so at 20 MHz clock it will most likely give a 50 ns delay (1/20 MHz).
|show 4 more comments|
Each processor has its own instruction set and therefore its own assembly language. Actually, there can be different assemblers for the same processor, each with a bit different syntax. It is the assembler that specifies what names you have to provide to indicate particular instructions. Typically assemblers will use the same names for instructions (called instruction mnemonics) that the documentation for the processor uses, but this is not always the case. You are asking about instructions on two different processors using different assemblers, so in general you can not assume any similarity just because the names are the same.
However, over the years a few common (certainly not standard though) instruction names have emerged. One such name is NOP, which refers to No OPeration. Most processors have a instruction that does nothing, and most assemblers name this instruction NOP. However, again, there is no guarantee that this is true of any one assembler so you should always check instead of assuming.
I am not familiar with the AVR instruction set, and certainly not familiar with it as presented by the arduino tools. I therefore don't know what the arduino NOP does that you are rerferring to. If it does in fact simply take one instruction cycle and do nothing more as the name NOP would suggest, then yes, it has the same effect as the PIC 12F675 (actually a 14 bit core device) NOP instruction. On the PIC traditional 14 bit core devices, NOP takes a single instruction word and executes in a single instruction cycle.
NOPs are usually used to insert short waits in code, like waiting a microsecond for a line to settle. By the way on this PIC, if you want to waste 2 instruction cycles, you can do it with the single instruction "GOTO $+1" with a few restrictions not worth getting into here.