Having spent some considerable time trying to understand the Bank selecting strategy employed in a PIC18F 4520 CPU, I still find it very confusing and would appreciate a clear explanation. From the data sheets, the access bank comprises 256 bytes of data Ram encompassing an address range of 00 - FF. Within that range, Addresses 00 - 7F comprise general purpose registers (GPR's) while addresses 80 - FF encompass the special function registers To modify data in the access bank requires you only to set the suffix 'a' in the instruction to 0. My confusion is over the fact that the SFR registers such as PORTA - PORTE are also listed as being in Bank 15. To access the PORTA register for example, do I have to explicitly set the BSR to 15 and set the suffix 'a' in the instruction to 1? or can I simply access PORT A using the suffix 'a' in the instruction set to 0? The movwf instruction states that if 'a' = 1, the bank select register is used to select the GPR bank (default) so presumably the BSR must be set to 15 prior to using the movwf instruction as follows:
movlb .15 ; select bank 15
movlw 0x0F
movwf PORTA,1 ; update PORT data
or is this better?
movlb .0 ; clear BSR
movlw 0x0F
movwf PORTA,0 ; force use of access bank
Any feedback would be appreciated ...suffered a minor stroke back in January, so I find that I need clarity of understanding before digging a deep hole for myself.
Thank you!!