$ is assembly for the current program counter value. It points to the next instruction to be executed so if the next instruction takes 2 bytes "goto $+2" skips the next instruction
$ is assembly for the current program counter value. It points to the next instruction to be executed so if the next instruction takes 2 bytes "goto $+2" skips the next instruction
You'll find the older 16F have a few quirks that are gone in the 18F
Wait till you hit the RMW bug. The good news is the new 14bit core fixes the quirks of the older 14bit core. Also seems the older 33 instruction core is at the end of development in favor of the updated 44 instruction core.
A good way to understand what is going on is to run the simulator in MPLAB. You can single step and watch the registers change. There is also a stopwatch so that you can see how long loops take.
Delay2sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto $+2 means move the program counter from the current program memory location to current memory location + 2. So PC + 1 = decfsz d2,f. And PC + 2 = the next goto $+2. That means it skips right to the bottom every time until that variable finishes counting down and becomes zero.
Have a look at Figure 13-1 on page 103
Each instruction takes 14 bits. Each time the program counter increments, it moves 14-bits higher in memory (to the next instruction).
Goto $+1 means move the PC (Program Counter) from the current position to the current position + 1 (increment it). In other words it just goto's to the next instruction. Pointless of course, since it was going there anyway.
Goto $+2 means move the PC two instructions ahead, skipping the next instruction. You can do the same thing with a label, but for little short skips like that, why bother? It's obvious (not to you yet, but you'll get it. ) what you're doing.
The instruction is: decrement the value in 'd1' register and place the result back into 'd1' .
The 'f' is the part of the instruction which tells the program where put the result of the decrement.
If the Instruction was decfsz d1, W it would decrement 'd1' and put the result in 'W', the working register.
The instruction is: decrement the value in 'd1' register and place the result back into 'd1' .
The 'f' is the part of the instruction which tells the program where put the result of the decrement.
If the Instruction was decfsz d1, W it would decrement 'd1' and put the result in 'W', the working register.
The instruction is: decrement the value in 'd1' register and place the result back into 'd1' .
The 'f' is the part of the instruction which tells the program where put the result of the decrement.
If the Instruction was decfsz d1, W it would decrement 'd1' and put the result in 'W', the working register.
No, the decfsz d1,f and other 'dec's always change the contents of d1 reg by '1'.
Likewise a incf d1,f would always increment the contents of d1 reg by '1'.
If you wanted to change the contents of d1 reg by more than '1' you could use
add or sub intructions.
EDIT:
All of these instructions are on the PIC datasheet