goto PIC Tips
'Equivalent Operation(s)' what's with the numbers?
These Pseudo instructions are taken from the Help file in Microchip's MPLAB IDE. See under Help - Topics - MPASM Assembler - Reference - Instruction Sets
The meaning of the 'Equivalent Operation(s)' is a little confusing because they use numbers without explaining what they mean. If you dig into the datasheet for the PIC and look at the instruction set it will become clearer (maybe), but for a quick explanation see below.
The numbers are the file register and bit position. The Special File Register (SFR) at address 3 is the STATUS register and within the STATUS register the bits are numbered as:
So the instruction BSF 3,0 could also be written as BSF STATUS, C. This mean Set the Carry bit in the STATUS register.
Another examples BTFSC 3,2 is the same as BTFSC STATUS, Z meaning 'skip next instruction if Z flag bit is clear'
The other instruction that looks confusing is the f,d (SFR, Destination). For example DECF f,d. Here f is the file register and d the destination. If d == 0 then the result is placed in the W register, if d == 1 the result is placed back in the file register.
When writing code you should use names rather than numbers otherwise your code will be hard for you to understand while you're writing it and nigh on impossible for you or anyone else later.
So rather than writing MOVF 5,0 which is saying move the contents of file register address 5 (PORTA) to destination 0 (W register) you'd write MOVF PORTA, W - easy to see what's going where.
Device Specifc Include Files and Templates
The include file for each device has all the Special Functions Register names and bit names defined so all you need to do is include the correct file and start writing code, no need to manually define them yourself.
If you're using the MPLAB IDE you will find
include files for all the PIC variants in
If your using the MPLAB IDE you can find assembler .ASM template files which are an even better way to get started. These are located in C:\Program Files\Microchip\MPASM Suite\Template\Code an example file looks like this 16F628ATEMP.ASM Just remember to use save as and put it in a working directory - don't overwrite the original!