Path: utzoo!dciem!nrcaer!scs!spl1!laidbak!att!pacbell!ames!pasteur!ucbvax!decwrl!mejac!gryphon!crash!jeh From: jeh@crash.cts.com (Jamie Hanrahan) Newsgroups: comp.os.vms Subject: Re: MACRO SUBxy VS. CMPx question Message-ID: <3068@crash.cts.com> Date: 4 Jun 88 03:34:43 GMT Article-I.D.: crash.3068 References: <581185542.0.RIC@RML2.SRI.COM> Reply-To: jeh@crash.CTS.COM (Jamie Hanrahan) Organization: Crash TS, El Cajon, CA Lines: 22 Summary: You're right, they're inverted 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?)