Shop OBEX P1 Docs P2 Docs Learn Events
How do I set a bit is assembly? — Parallax Forums

How do I set a bit is assembly?

Scott EstesScott Estes Posts: 10
edited 2008-10-27 18:12 in Propeller 1
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

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-10-27 18:12
    That would be

    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.
Sign In or Register to comment.