How do I set a bit is assembly?
Scott Estes
Posts: 10
The following snip sets the direction reg to output and toggles a pin.· What is the best way to set the direction reg pin 16 to input?
DAT
org 0
toggle
······· mov dira, setPin
:loop··xor outa, setPin
······· jmp #:loop
setPin long |< 16
DAT
org 0
toggle
······· mov dira, setPin
:loop··xor outa, setPin
······· jmp #:loop
setPin long |< 16
Comments
andn dira, setPin
this takes setPin, NOTs it (so every bit except the 16th bit is set), then ANDs it with the contents of dira. So the contents of dira will stay the same, except bit 16 which will be cleared.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.