Modifying bits with variables, not constants

gramo

New Member
Just trying to figure out the equivilent for Proton+ picbasic,

PICBASIC Pro bit setting/clearing with a variable:

porta.0[Variable] = 1 'sets bit(variable) of porta
porta.0[Variable] = 0 'clears bit(variable) of porta

Proton+ :

doesn’t work.. it can only modify register bits with addressing of constants in that manner.

If someone knows how to over come this - please let me know
 
I'm not familiar with that version of basic.
A generic way to do this would be,

PORTA = PORTA OR (1 << Variable)
To set the bit

and

PORTA = PORTA AND (255 - (1 << Variable))
To clear the bit.

The << operation is shift left. Variable would contain 0 to 7.

Mike.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…