Next Previous Contents

8. Macro packages

Using the .MACPACK directive, predefined macro packages may be included with just one command. Available macro packages are:

8.1 .MACPACK generic

This macro package defines macros that are useful in almost any program. Currently, two macros are defined:

        .macro  add     Arg
                clc
                adc     Arg
        .endmacro

        .macro  sub     Arg
                sec
                sbc     Arg
        .endmacro

8.2 .MACPACK longbranch

This macro package defines long conditional jumps. They are named like the short counterpart but with the 'b' replaced by a 'j'. Here is a sample definition for the "jeq" macro, the other macros are built using the same scheme:

        .macro  jeq     Target
                .if     .def(Target) .and ((*+2)-(Target) <= 127)
                beq     Target
                .else
                bne     *+5
                jmp     Target
                .endif
        .endmacro

All macros expand to a short branch, if the label is already defined (back jump) and is reachable with a short jump. Otherwise the macro expands to a conditional branch with the branch condition inverted, followed by an absolute jump to the actual branch target.

The package defines the following macros:

        jeq, jne, jmi, jpl, jcs, jcc, jvs, jvc


Next Previous Contents