Shop OBEX P1 Docs P2 Docs Learn Events
ASM IF condition synonyms- help — Parallax Forums

ASM IF condition synonyms- help

Ron CzapalaRon Czapala Posts: 2,418
edited 2010-09-01 15:09 in Propeller 1
Am I correct thinking that these three IF conditions work exactly the same?

IF_NC_AND_NZ
IF_NZ_AND_NC
IF_A

and similarly

IF_C_OR_Z
IF_Z_OR_C
IF_BE

If they are equivalent, why are the other versions necessary?

Comments

  • KyeKye Posts: 2,200
    edited 2010-09-01 09:19
    They are the same.

    It make life easier to code when you don't have to type them one and only one way.

    Also, IF_A is more readable then IF_NZ_AND_NC.
  • Nick McClickNick McClick Posts: 1,003
    edited 2010-09-01 10:24
    Related question -

    If I use a flag to do a jmp (or execute another instruction), does it clear the flag?
  • jazzedjazzed Posts: 11,803
    edited 2010-09-01 11:02
    Flags C and Z can only be changed if you add wc and/or wz after the instruction, and then they will only be changed based on the instruction behavior.
  • ericballericball Posts: 774
    edited 2010-09-01 12:30
    @Ron Czapala
    Yes they are equivalent. IF_A / IF_B are shorthand for if_above / if_below and assume that the previous opcode was the appropriate comparison with wc,wz.

    @Nick McClick
    The flags will only be changed if the opcode is executed (so the flag comparison is true) and the opcode has wc or wz set. This can be useful:
    ' if ( a == 1 || a == 2 || a == 3 )
    		CMP	A, #1	wz
    	if_nz	CMP	A, #2	wz
    	if_nz	CMP	A, #3	wz
    	if_z	JMP	#iftrue
    
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-09-01 15:09
    Thanks for your responses.

    The duplicate and triplicate instructions threw me but I guess I can see that they might make the code "read easier" depending on the prevoius instructions.
Sign In or Register to comment.