Bank switching is sometimes annoying, but there is a simplier way to do that BSF/BCF instructions. There is a banksel dirrective/macro in MPLAB, that helps a lot, so for example "old" bank switching code:
Code:
BSF STATUS,RP0 ;go to TRISA bank
Can be changed to:
Code:
banksel TRISA
or to
Code:
banksel 1
This is pretty usefull when your PIC has more than 2 banks, so you don't have to read the datasheet every time you want to use new SFR
The banksel dirrective/macro is producing BSF/BCF instruction(s) for you, so this is much easier.
As already suggested, you should use the labels from the MicroChip include files, this tells you (at least vaguely!) what the line is doing. 'STATUS' is far more informative than '03h', as Jay has suggested, you can also use the inbuilt macros which will generate the lines for you with a 'banksel' instruction - but for tutorial purposes I thought this might be more confusing?.
As already suggested, you should use the labels from the MicroChip include files, this tells you (at least vaguely!) what the line is doing. 'STATUS' is far more informative than '03h', as Jay has suggested, you can also use the inbuilt macros which will generate the lines for you with a 'banksel' instruction - but for tutorial purposes I thought this might be more confusing?.
Yes, all the include file does is act as a data file for 'text replacement' during assembly, so each word that matches one in the include file will be replaced by the value in the file.
It's well worth having a quick look through the include file, it can help you understand better what's happening.