"Michael J. Mahon" wrote:
> inc16   mac                     ; Increment 16-bit word
>          inc   ]1
>          do    ]1+1/$100         ; If ]1 is non-page zero
>          bne   *+5               ; - No carry.
>          else                    ; Else if ]1 on page zero
>          bne   *+4               ; - No carry.
>          fin
>          inc   ]1+1              ; Propagate carry.
>          eom

This can be simpler:

INCW MAC
     INC ]1
     BNE Z
     INC ]1+1
Z    EOM


> cmp16   mac                     ; Compare 16-bit words
>          lda   ]1                ; Lo byte of first operand
>          cmp   ]2                ; Lo byte of second operand
>          lda   ]1+1              ; Hi byte of first operand
>          sbc   ]2+1              ; Hi byte of second operand
>          eom

This one cannot handle a comparison against a constant.
My version uses a couple of helper macros that are used
in other macros as well.

LDHI MAC
     IF #=]1
     LDA ]1/256
     ELSE
     LDA ]1+1
     FIN
     EOM

SBHI MAC
     IF #=]1
     SBC ]1/256
     ELSE
     SBC ]1+1
     FIN
     EOM

CMPW MAC
     LDA ]1
     CMP ]2
     >>> LDHI,]1
     >>> SBHI,]2
     EOM

--
Paul R. Santa-Maria
Monroe, Michigan USA



"Michael J. Mahon" wrote:
> I have been frustrated by my inability to get Merlin to define a
> global label in a macro that is referenceable outside a macro, and
> this, unfortunately, is no exception.
> Do you know a way to accomplish this?

Do you mean this?

                1             ORG   $5678      
                2    TESTMAC  MAC              
                3             NOP              
                4    ]VAR     EQU   *          
                5             NOP              
                6             EOM              
                7    ]VAR     =     $1234      
5678: 34 12     8             DA    ]VAR       
                9             >>>   TESTMAC    
567A: EA        9             NOP              
                9    ]VAR     EQU   *          
567B: EA        9             NOP              
                9             EOM              
567C: 7B 56     10            DA    ]VAR       


> I also usually write the "]1+1" part as "1+]1"
> so that it can handle indexed operands.

Another great tip!  Thanks again.

--
Paul R. Santa-Maria
Monroe, Michigan USA