Shop OBEX P1 Docs P2 Docs Learn Events
How to invert all bits in ASM (NOT instruction) — Parallax Forums

How to invert all bits in ASM (NOT instruction)

peterzpeterz Posts: 59
edited 2007-01-07 17:22 in Propeller 1
Is there an equivalent to NOT instruction in ASM ?
I want to invert all bits in a variable located in an ASM block.

·

Comments

  • Graham StablerGraham Stabler Posts: 2,510
    edited 2007-01-07 12:04
    You could use ANDN and use your value for both arguments?

    Or XOR with 111111.......

    Graham

    p.s. This is really handy: http://forums.parallax.com/forums/default.aspx?f=25&m=157555
  • peterzpeterz Posts: 59
    edited 2007-01-07 12:17
    But I want to invert a full 32bits value and the ASM complaints: constant cannot exceed $1FF

    For example I cannot do:

    xor t1,#$FFFFFFFF
  • Remy BlankRemy Blank Posts: 42
    edited 2007-01-07 12:34
    peterz said...
    But I want to invert a full 32bits value and the ASM complaints: constant cannot exceed $1FF

    For example I cannot do:

    xor t1,#$FFFFFFFF
    You'll have to store your $ffffffff constant in a long:
    xor   t1, allOne
    ...
    allOne   long $ffffffff
    


    -- Remy
  • Jasper_MJasper_M Posts: 222
    edited 2007-01-07 17:22
    Graham Stabler said...
    You could use ANDN and use your value for both arguments?

    That wouldn't actually work - it would and the ORIGINAL value with it's inverted value, resulting in zero. eg.

    if you'd andn %1001 with itself, the result would be %1001 & %0110 = %0000. Therefore XORing with $FF_FF_FF_FF seems to be the only real option.
Sign In or Register to comment.