Shop OBEX P1 Docs P2 Docs Learn Events
Having Trouble with PASM TEST Instruction — Parallax Forums

Having Trouble with PASM TEST Instruction

JonnyMacJonnyMac Posts: 9,194
edited 2009-04-25 17:25 in Propeller 1
I'm baffled over something that should be stupidly easy. This works as I expect:

testbit                 mov     tmp1, ina
                        and     tmp1, pinMask           wz
        if_z            wrlong  zero, pinStatus
        if_nz           wrlong  one, pinStatus
                        jmp     #testbit


... but this version doesn't; it always returns 0 even when the pin is high.

testbit                 test    ina, pinMask            wz
        if_z            wrlong  zero, pinStatus
        if_nz           wrlong  one, pinStatus
                        jmp     #testbit


I must be missing something but, for the life of me, have not been able to deduce what that something is....

Comments

  • JonnyMacJonnyMac Posts: 9,194
    edited 2009-04-25 16:37
    Okay, never mind -- problem solved by switching the order of operators for test

    testbit                 test    pinMask, ina            wz
            if_z            wrlong  zero, pinStatus
            if_nz           wrlong  one, pinStatus
                            jmp     #testbit
    


    This version works but as both pinMask and ina are variables I don't understand why the order matters.

    Post Edited (JonnyMac) : 4/25/2009 4:42:46 PM GMT
  • Bill HenningBill Henning Posts: 6,445
    edited 2009-04-25 17:16
    "ina" is a special register, only accessed properly when it is in the "source" part of the instruction - when in the "destination" part you access the "shadow" ram "beneath" it.
    JonnyMac said...
    Okay, never mind -- problem solved by switching the order of operators for test

    testbit                 test    pinMask, ina            wz
            if_z            wrlong  zero, pinStatus
            if_nz           wrlong  one, pinStatus
                            jmp     #testbit
    


    This version works but as both pinMask and ina are variables I don't understand why the order matters.
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com - a new blog about microcontrollers
  • JonnyMacJonnyMac Posts: 9,194
    edited 2009-04-25 17:25
    Thanks for the clarification, Bill. For as much BASIC Stamp experience as I have I should have figured that out.
Sign In or Register to comment.