• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Indirect Addressing

Status
Not open for further replies.

dramrattan

New Member
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?
 

Mike - K8LH

Well-Known Member
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
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top