Continue to Site

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.

  • 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.

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.

Latest threads

New Articles From Microcontroller Tips

Back
Top