Shop OBEX P1 Docs P2 Docs Learn Events
TEST and INA ? — Parallax Forums

TEST and INA ?

jazzedjazzed Posts: 11,803
edited 2008-03-18 18:25 in Propeller 1
Maybe I haven't had enough coffee, but .... does INA work with the TEST instruction?

'This works

                mov     rxbit,          ina
                test    rxbit,          #2 wz ' test value & convert to bool
                if_z    mov     rxbit,  #0
                if_nz   mov     rxbit,  #1

'This doesn't ????

                test    ina,            #2 wz ' test value & convert to bool
                if_z    mov     rxbit,  #0
                if_nz   mov     rxbit,  #1


TIA


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
jazzed·... about·living in·http://en.wikipedia.org/wiki/Silicon_Valley

Traffic is slow at times, but Parallax orders·always get here fast 8)

Comments

  • nutsonnutson Posts: 242
    edited 2008-03-18 15:27
    Look in the "tips and traps" sticky page 6. INA cannot be used as·the destination register
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2008-03-18 15:43
    jazzed,

    nutson·is correct.· Look at Chapter 1 for the Propeller (1:Introducing the Propeller Chip) on the first page (page 23 of the propeller manual hard copy)

    There, you will find a table of registers that states that the INA, because it is a read-only register is·"...Only accessible as a Source Register (i.e. MOV DEST,SOURCE)."

    Since you can't have a constant in the DEST field either, you can pre-define a variable value to use in the DEST, so your code might look something like this.

                    test    temp_var,      ina wz ' test value & convert to bool
                    if_z    mov     rxbit,  #0
                    if_nz   mov     rxbit,  #1
    
    rxbit         long      0
    temp_var      long      2
    



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • jazzedjazzed Posts: 11,803
    edited 2008-03-18 16:05
    Great [noparse]:)[/noparse] Thanks for suggesting the cycle saving alternative Beau.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    jazzed·... about·living in·http://en.wikipedia.org/wiki/Silicon_Valley

    Traffic is slow at times, but Parallax orders·always get here fast 8)
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2008-03-18 18:14
    jazzed,

    To save cycles, you should also look at the MUXNZ operator...

                    test    temp_var,      ina wz ' test value & convert to bool
                    muxnz   rxbit,  #1
    
    
    rxbit         long      0
    temp_var      long      2
    
    

    smilewinkgrin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • jazzedjazzed Posts: 11,803
    edited 2008-03-18 18:25
    Cool 8-) I almost made that connection. Thanks for the push [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    jazzed·... about·living in·http://en.wikipedia.org/wiki/Silicon_Valley

    Traffic is slow at times, but Parallax orders·always get here fast 8)
Sign In or Register to comment.