Shop OBEX P1 Docs P2 Docs Learn Events
Testing INA values over an OUT pin (in ASM) — Parallax Forums

Testing INA values over an OUT pin (in ASM)

peterzpeterz Posts: 59
edited 2007-01-08 01:45 in Propeller 1
I have·PIN1 that I·set as OUT and change values at certain times in·a Spin·program.
So I do, in Spin:
...
OUTA[noparse][[/noparse]1]:=1
...
OUTA[noparse][[/noparse]1]:=0
...
etc

In the ASM part of the program I test this pin from time to time·to check its value. For this I use an INA instruction.
I use the following code to test this pin:

test··· 2, ina wc
if_c jmp #Is_One

However the condition is·never met, that is, I never detect it as 1, despite I put the PIN1 to 1 many times while in the Spin part.

First question, is it right to perform an INA over an OUT pin ?
Second, is this·the right way to perform the test ?

Comments

  • SSteveSSteve Posts: 808
    edited 2007-01-07 20:28
    I'm guessing you are wanting to test against the literal value 2 rather than the contents of register 2 which is what you are really doing. Try this:

    test pinMask, ina wc
    ...
    pinMask long %0010

    You can't use ina as the destination and you can't use a literal value as the destination, so you have to put the test mask in a DAT statement.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows

    links:
    My band's website
    Our album on the iTunes Music Store
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2007-01-07 21:24
    If you are trying to check pin 1 you could do:

    test ina,#2 wc

    Also labels tend to be written as :Is_One so it would be

    jmp #:Is_One

    But I'm not sure if the : is just a convention, I suspect so.

    Graham
  • SSteveSSteve Posts: 808
    edited 2007-01-07 22:12
    Graham Stabler said...
    If you are trying to check pin 1 you could do:

    test ina,#2 wc
    That will not work. You can't use ina as a destination register. The compiler won't complain, but the code won't work. Take a look at the second entry on page 6 of the Propeller Tricks & Traps document.
    Graham Stabler said...
    Also labels tend to be written as :Is_One so it would be

    jmp #:Is_One

    But I'm not sure if the : is just a convention, I suspect so.
    The colon isn't just a convention, it makes a label local. A local label's scope is between two non-local labels. This is to make it possible to use multiple instances of generic labels. Example:

    Section1 mov counter, #16
    :loop add this, that
        ...
      djnz counter, #:loop
    Section2 mov counter, #16
    :loop sub theother, thing
        ...
      djnz counter, #:loop
    
    


    Without the colons, the above code wouldn't compile.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows

    links:
    My band's website
    Our album on the iTunes Music Store
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2007-01-07 22:21
    Ah, I assumed that because it wasn't really a destination for the test command it would not mind. I guess that's why its a trap.

    The : thing shows how programming languages are like normal langauges, I have just always used the : since the start but never learnt why.

    Graham
  • big_markbig_mark Posts: 49
    edited 2007-01-08 00:40
    SSteve said...
    This is to make it possible to use multiple instances of generic labels.

    I am assuming (hoping) that you mean reusing labels in different objects, and not in the same block of assembly, even in different functions? Sounds like a potential debugging nightmare to me.
  • SSteveSSteve Posts: 808
    edited 2007-01-08 00:50
    That's what the local label capability is designed for, but just because you can use identical labels in the same block of assembly doesn't mean you have to. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows

    links:
    My band's website
    Our album on the iTunes Music Store
  • big_markbig_mark Posts: 49
    edited 2007-01-08 00:59
    It still sounds a little sloppy to me. I can't think of any good reason to allow multiple uses of the same label in a block of code. If one must use the label "loop", for example, at least make the label unique. So "loop" becomes "Subroutinename_loop" for instance. Its not like it'll take up any extra Propellor RAM...

    Mark
  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-08 01:45
    Part of the reason for local labels is to avoid the need for other local references like "$+1" or "$-1" where "$" is the current instruction location. Often these are very useful and a complex descriptive label is not helpful in understanding the code.
Sign In or Register to comment.