Shop OBEX P1 Docs P2 Docs Learn Events
Store/Retrieve WC,WZ ? — Parallax Forums

Store/Retrieve WC,WZ ?

scottascotta Posts: 168
edited 2007-11-05 18:15 in Propeller 1
How do you Store/Retrieve WC,WZ ?

Scott

Comments

  • BergamotBergamot Posts: 185
    edited 2007-11-05 15:53
    Cue desilva in 3, 2, 1...
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-05 15:57
    You use conditional execution to do something or not do something that stores the value in a memory location. For example:
         if_c   or     saved,#1
         if_nc andn saved,#1
         if_z   or     saved,#2
         if_nz andn saved,#2
    


    or
                 mov  saved,#0
         if_c   or     saved,#1
         if_z   or     saved,#2
    
  • rokickirokicki Posts: 1,000
    edited 2007-11-05 17:43
    To make restoration easier, you may want to set the bits so you can restore them in a single operation.
    Something like this might work:

            mov saved,#0
    if_c   or saved,hibit
    if_nz or saved,#1
    
    



    Then to restore you just need to

           add saved,saved wc,wz
    
    



    for a destructive save, or

    <pre>
    mov acc,saved
    add acc,saved wc,wz
    </pre>

    for a nondestructive save.
  • hippyhippy Posts: 1,981
    edited 2007-11-05 18:01
    I haven't tested it but aren't the MUX opcodes useful here ...

    ' To save both flags ...
    
    MUXNZ flags,#2
    MUXC  flags,#1
    
    ' To reload both flags ...
    
    SHR flags,#1 WC, WZ, NR
    
    
    
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-05 18:15
    Thanks, hippy. That's even cleaner and shorter.
Sign In or Register to comment.