Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC: Clear bit with bitnummer as variable?

Status
Not open for further replies.

msmax

Full Member level 1
Joined
May 6, 2001
Messages
99
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Pays Bas
Activity points
919
pic clear bit

Using MPLAB for a small project:

I like to clear a bit in a register using the value of an other register.

for example:

INCF Count,F
BCF Reg, Count

This doesn't seem to work, cause BCF only accepts literals.
Any idea how to do this in a easy way?
 

C-Man

Advanced Member level 4
Joined
Jul 19, 2001
Messages
1,059
Helped
90
Reputation
180
Reaction score
17
Trophy points
1,318
Activity points
10,189
This can not work, you could define a table of the 8 bit positions

like
addwf pcl,F
retlw 0x01 or 0xFE if you want to clear Bit 0
retlw 0x02 or 0xFD if you want to clear Bit 1
....

and then call this routine with your "variable" in W

movf count,W
call xxxx
andwf Reg,F to clear bit X or iorwf Reg,F to set bit X

Complicated, but I have no other idea :)

best regards
 

msmax

Full Member level 1
Joined
May 6, 2001
Messages
99
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Pays Bas
Activity points
919
Thanks for the info.

May be not the most simple routine, but it works fine for me.

Good THINKING!
 

nebisman

Full Member level 4
Joined
Apr 13, 2002
Messages
226
Helped
10
Reputation
22
Reaction score
9
Trophy points
1,298
Activity points
1,849
other way "multiplication algorithm


use a dummy register f1
in f2 is the value of your bit. value is in orther 0 to 7

movlw b'11111111';
movwf f1
bcf status,c
loop rlf f1,f;
decfsz f2
goto loop
movf f1,w;
andwf yourfile
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top