Shop OBEX P1 Docs P2 Docs Learn Events
Rename ANYB? — Parallax Forums

Rename ANYB?

SeairthSeairth Posts: 2,474
edited 2015-10-24 20:53 in Propeller 2
Currently, ANYB is implemented as an OR that does not write to D. What I'm expecting is to see if any of the bits in D are set, based on the mask in S. That would mean AND.

What is the use case for OR?

Edit: Oh wait. That's TEST. Hmm... maybe we just need a better name for ANYB....

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2015-10-24 22:27
    TESTB, TESTOR
    If TESTOR, perhaps TEST could become TESTAND ?

    Or even perhaps ANDNR and ORNR (ie NR=no result)
    or ANDTEST and ORTEST ?
  • ANYB is quick check on two registers being zero.
  • cgraceycgracey Posts: 14,152
    ozpropdev wrote: »
    ANYB is quick check on two registers being zero.

    Right.

    Between S and D, are ANYBits set? Use WZ to find out.
  • cgracey wrote: »
    ozpropdev wrote: »
    ANYB is quick check on two registers being zero.

    Right.

    Between S and D, are ANYBits set? Use WZ to find out.

    This seems like a niche instruction. Another one that could be freed up for another instruction.
  • cgraceycgracey Posts: 14,152
    Seairth wrote: »
    cgracey wrote: »
    ozpropdev wrote: »
    ANYB is quick check on two registers being zero.

    Right.

    Between S and D, are ANYBits set? Use WZ to find out.

    This seems like a niche instruction. Another one that could be freed up for another instruction.

    It's a freebie. We've still got open instruction slots.
  • ozpropdev wrote: »
    ANYB is quick check on two registers being zero.

    ozpropdev you can check if two registers are zero with an 'or' instruction p1 code example below.
    or reg1, reg2     wz
    if_z jmp #:bothRegsZero
    
  • ozpropdev wrote: »
    ANYB is quick check on two registers being zero.

    ozpropdev you can check if two registers are zero with an 'or' instruction p1 code example below.
    or reg1, reg2     wz
    if_z jmp #:bothRegsZero
    

    nice one!

    Mike

  • Thanks Mike! that was a programming technique I learned many years ago, that I thought I would share.

    Jeff
  • Yes but ANYB does not destroy the D rges contents. Its a no write result instruction.
    In P1 we can use NR but we don't have that facility in P2.
  • Though not a substitute for ANYB, I'll point out that any instruction can be turned into a no-write instruction with:
    	altds	nowrite, #%100_000_000
    	or	reg1, reg2 wz
    	
    nowrite	long	inb << 19
    
  • Or you could just do
            mov     tempreg, reg1
            or      tempreg, reg2 wz
    
  • OR quick and easy as I originally stated. :)
        anyb    reg1,reg2 wz
    
    use case: checking for a 64bit zero result.
  • RaymanRayman Posts: 14,640
    Off the top, I think I'd call it "testz" for "test zero"...
  • Guys thank you for all of the suggestions on how to make it non-destructive to the D register.
    Yes ANYB is a better alternative, than what I suggested, if it were written for the P2.
    My example works on the P1 and you can set the NR flag, it could work on the P2 if you don't care
    if the D register gets overwritten.

    Jeff
  • cgraceycgracey Posts: 14,152
    What if you needed to find if any bit among 256 were set?
    		anyb	r0,r1	wz
    	if_z	anyb	r2,r3	wz
    	if_z	anyb	r4,r5	wz
    	if_z	anyb	r6,r7	wz
    
    	if_z	jmp	#gotzero
    
  • ANYB makes perfect sense now. :)
  • Yes Chip I really like your example in testing if any bits out of 256 are set.
    I bet people are really having fun testing P2 code.
    The P2 is really going to be special when it is done!!!

    Jeff
  • RaymanRayman Posts: 14,640
    Maybe carry should set if all ones?
  • cgraceycgracey Posts: 14,152
    Rayman wrote: »
    Maybe carry should set if all ones?

    Right now, OR/ANYB set C to the parity of the result. That's what all the AND/OR/XOR instructions currently do. To have it set C if all highs would mean a 32-input AND gate and mux.

    AND's need to set C to parity for things like bit filters and LFSR tests.

    OR's might be better setting C to reflect all highs.
Sign In or Register to comment.