Shop OBEX P1 Docs P2 Docs Learn Events
To NEG or not to NEG, that is the question — Parallax Forums

To NEG or not to NEG, that is the question

ozpropdevozpropdev Posts: 2,791
edited 2014-08-02 18:04 in Propeller 2
In the P1 and the propsed P2 instruction set we have 5 variants of the NEG instruction.
P2 aka P16X64A instructins
--------------------------

ZCWS		0110011 ZCI CCCC DDDDDDDDD SSSSSSSSS		NEG	D,S/#		inc

ZCWS		0110100 ZCI CCCC DDDDDDDDD SSSSSSSSS		NEGC	D,S/#		inc
ZCWS		0110101 ZCI CCCC DDDDDDDDD SSSSSSSSS		NEGNC	D,S/#		inc
ZCWS		0110110 ZCI CCCC DDDDDDDDD SSSSSSSSS		NEGZ	D,S/#		inc
ZCWS		0110111 ZCI CCCC DDDDDDDDD SSSSSSSSS		NEGNZ	D,S/#		inc

Do we really need the last 4 variants as they can be replicated with conditional versions
of the standard NEG instruction. Can't they?
	if_c	neg	d,s#	'replaces negc
	if_nc	neg	d,s#	'replaces negnc
	if_z	neg	d,s#	'replaces negz
	if_nz	neg	d,s#	'replaces negnz

Am I missing something here?
Brian :)

Comments

  • cgraceycgracey Posts: 14,133
    edited 2014-08-02 09:33
    Remember that they do a move, conditionally negating the value written to the destination. In some cases, this saves another instruction. These instructions were "free", in terms of transistors and they are cousins to the SUMxx instructions.
  • ozpropdevozpropdev Posts: 2,791
    edited 2014-08-02 18:04
    Thanks Chip!
    As soon as I read "move" in your explanation, the penny dropped.
    In my use/test cases I am using the same source and destination address.
    I read the docs multiple times and still managed to miss the fundamental stuff. Yikes!
    Thanks for putting me on the straight and narrow.
    The forum saves the day again. :)
    Cheers
    Brian
Sign In or Register to comment.