changing byte value without changing one bit

Bloody-orc

Senior Member
Hi there

Is there an easy and fast way of changing a byte without changing bit3 (4'th from right side). i need to do this to 18X outputs but on 3rd pin runs PWM. and on others run motor with H-Briidge so i have to change 4 pins wery frequently and fast...

Regards
Rain
 

hippy

Ex-Staff (retired)
An example ...

- b3 = b3 & %00001000 | b4

You'll need to ensure bit 3 of b4 ( in this example ) is kept clear, or use ...

- b4 = b4 & %11110111
- b3 = b3 & %00001000 | b4

If you are just manipulating output pins, the current output pin values can be obtained by using "PEEK $30" ...

- b4 = <i>new value to set </i>
- PEEK $30,b3
- pins = b3 &amp; %00001000 | b4
 
Top