[comp.os.vms] MACRO SUBxy VS. CMPx question

jeh@crash.cts.com (Jamie Hanrahan) (06/04/88)

In article <581185542.0.RIC@RML2.SRI.COM> RIC@RML2.SRI.COM (Ric Steinberger) writes:
>In studying the MACRO language I have concluded that the CMPx (compare)
>instruction sets bits in the PSL based on the operation (arg1 - arg2),
>whereas SUBxy (subtract) sets bits based on (arg2 - arg1).  
>	[...example program omitted...]
>Is there a good explanation for why DEC sets bits resulting from a CMPx
>instruction differently than if one had used the same arguments in a SUBxy
>instruction?  Or have I reached an erroneous conclusion.

You're correct.  Don't try to think of CMPx as a subtraction.  Instead,
remember that in the sequence

	CMPL	A, B
	BLSS	10$

the branch is taken if A is less than B.  Think of the comparison 
operation as being inserted between the two operands of the compare.  

Whereas SUBx2 A, B means "subtract A from B, and store result in B"
because whereever a VAX instruction has a "destination" operand, 
that operand is always the final operand(s).  (Why?  I dunno.  Maybe 
because it was that way on the PDP-11?)