Shop OBEX P1 Docs P2 Docs Learn Events
V19 "ENCOD" instruction changes from V18's "TOPONE" instruction — Parallax Forums

V19 "ENCOD" instruction changes from V18's "TOPONE" instruction

Chip
In V18 we had the "TOPONE" instruction that returns the position of the "top" 1 bit in S into D.
The C flag was set if there were no 1's in D and Z set if result was zero.
$00000000 $00 CZ
$00000001 $00 _Z
$00000002 $01 __
$00000004 $02 __
$00000008 $03 __
$00000010 $04 __
$00000020 $05 __
$00000040 $06 __
$00000080 $07 __
$00000100 $08 __
$00000200 $09 __
$00000400 $0A __
$00000800 $0B __
$00001000 $0C __
$00002000 $0D __
$00004000 $0E __
$00008000 $0F __
$00010000 $10 __
$00020000 $11 __
$00040000 $12 __
$00080000 $13 __
$00100000 $14 __
$00200000 $15 __
$00400000 $16 __
$00800000 $17 __
$01000000 $18 __
$02000000 $19 __
$04000000 $1A __
$08000000 $1B __
$10000000 $1C __
$20000000 $1D __
$40000000 $1E __
$80000000 $1F _
In V19 the instruction was changed to "ENCOD".
It also returns the "top" 1 position of S into D.
A big difference though is C is set to D[0] while Z is set when D is zero.
$00000000 $00 _Z
$00000001 $00 _Z
$00000002 $01 C_
$00000004 $02 __
$00000008 $03 C_
$00000010 $04 __
$00000020 $05 C_
$00000040 $06 __
$00000080 $07 C_
$00000100 $08 __
$00000200 $09 C_
$00000400 $0A __
$00000800 $0B C_
$00001000 $0C __
$00002000 $0D C_
$00004000 $0E __
$00008000 $0F C_
$00010000 $10 __
$00020000 $11 C_
$00040000 $12 __
$00080000 $13 C_
$00100000 $14 __
$00200000 $15 C_
$00400000 $16 __
$00800000 $17 C_
$01000000 $18 __
$02000000 $19 C_
$04000000 $1A __
$08000000 $1B C_
$10000000 $1C __
$20000000 $1D C_
$40000000 $1E __
$80000000 $1F C_
This C flag change slipped under my "P2 Radar" and had me "wheel-spinning" for a while.
I personally prefer the V18 version as NC indicated that a valid position value was in D.
Was there a particular reason for this change to C's behaviour?


Comments

  • cgraceycgracey Posts: 14,152
    There was no strong reasoning behind the change. I'll put it back to how it was before. Sorry about that.
  • cgraceycgracey Posts: 14,152
    I just put it back the way it used to be, so that C=1 when S=0.
Sign In or Register to comment.