Shop OBEX P1 Docs P2 Docs Learn Events
Assembler question — Parallax Forums

Assembler question

micman2micman2 Posts: 18
edited 2011-05-20 07:26 in Propeller 1
Hi all,
How I do convert this function C in assembler PASM

flag = 0;

if ( flag == 0 ) & ( Pin_7 == 1) {
flag = 1;
....
.......
.....
} else if ( flag == 1 ) & ( Pin_7 == 0 ) {
flag = 0;
....
.......
.....
}

Comments

  • Mark_TMark_T Posts: 1,981
    edited 2011-05-20 02:55
    Something like:
            mov    flag, #0
            ...
            ...
            cmp    flag, #0  wz
      if_z  cmp    Pin_7, #1  wz
      if_nz jmp    #:elseif
            mov    flag, #1
            ....
            ....
            jmp    #:end
    :elseif cmp    flag,  #1  wz
      if_z  cmp    Pin_7, #0  wz
      if_nz jmp    #:end
            mov    flag, #0
            ...
            ...
    :end
    
  • micman2micman2 Posts: 18
    edited 2011-05-20 04:37
    good, thanks you!
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-05-20 07:26
    I think this might work, too:
    cmp     flag, #0                wz
                            test    p7mask, ina             wc
            if_z_and_c      mov     flag, #1
            if_nz_and_nc    mov     flag, #0
    

    Still, value in flag could simply follow what's on P7 -- unless flag is able to have a non-zero value other than one (and if that's the case, my code is bogus).
Sign In or Register to comment.