PORTA is at address 0x05 and its direction register, TRISA, is at address 0x85,
which means that PORTA is in Bank 0 and TRISA is in Bank 1. Therefore either
indirect addressing or bank switching must be performed to access the direction register. How do i writea simply assembly code to show how PORTA can be initialized using indirect addressing mode for the PIC16F877?
You can indirectly access locations in bank 0 and 1 or in bank 2 and 3 by clearing or setting the IRP bit in the STATUS register, respectively.
Mike
Code:
;
clrf STATUS ; force bank 0 and IRP = 0 |B0
movlw TRISA ; address of TRISA |B0
movwf FSR ; FSR = &TRISA (in bank 1) |B0
clrf PORTA ; set PORTA latches to 0 |B0
clrf INDF ; TRISA = b'00000000' (outputs) |B0