Bit Moving

Status
Not open for further replies.

ibwev

Member
Using assembly for PIC16F690, is it possible to move a single bit from one register into another withour effecting the other bits? I am attempting to use a shadow register with PORTA,5 to toggle an led without effecting PORTA <4:0>.
 
Using assembly for PIC16F690, is it possible to move a single bit from one register into another withour effecting the other bits? I am attempting to use a shadow register with PORTA,5 to toggle an led without effecting PORTA <4:0>.

Yes, it is possible to do that. What bit do you want to test and move onto porta bit 5?

Code:
;
        movf    PORTA,W         ; use WREG as a port shadow
        iorlw   b'00010000'     ; set RA4 shadow unconditionally
        btfss   <portx>,<bit#>  ; is source bit a '1'?  yes, skip, else
        xorlw   b'00010000'     ; clear the RA4 shadow bit
        movwf   PORTA           ; update PORTA from shadow
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…