Shop OBEX P1 Docs P2 Docs Learn Events
Assembly If/Else statement — Parallax Forums

Assembly If/Else statement

Mag748Mag748 Posts: 266
edited 2014-08-12 09:18 in Propeller 1
Hello,

I was trying to think of how to do an If/Then statement in assembly and came up with the seemingly crude way of doing it. Although it does work fine, I wanted to know if there is a better way.
                mov      t0,       mode                  
                shr      t0,       #1        wc          ' If Mode & $01 == $01
  if_nc         jmp      #skip
                shl      tPat,     #1        wc          ' Then shift tPat right 1,
  if_nc         xor      outa,     pinMask               ' and Toggle Output if tPat & $01 == zero.
skip                                                     ' Else do nothing.

Any thoughts?


Thanks,
Marcus

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2014-08-12 07:32
    Try this:
    test    mode, #1 wz
            if_nz   shl     tPat, #1 wc
            if_a    xor     outa, pinMask
    
  • Mag748Mag748 Posts: 266
    edited 2014-08-12 09:18
    kuroneko wrote: »
    Try this:
    test    mode, #1 wz
            if_nz   shl     tPat, #1 wc
            if_a    xor     outa, pinMask
    

    Ah ha, I though the test instruction might be needed somewhere. And I'm still wrapping my head around all the if_x conditions. That worked perfectly.

    Thanks!
    -Marcus
Sign In or Register to comment.