Using the
.MACPACK
directive, predefined
macro packages may be included with just one command. Available macro packages
are:
.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
.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
.MACPACK cbm
The cbm macro package will define a macro named scrcode
. It takes a
string as argument and places this string into memory translated into screen
codes.
.MACPACK cpu
This macro package does not define any macros but constants used to examine
the value read from the
.CPU
pseudo variable. For
each supported CPU a constant similar to
CPU_6502
CPU_65SC02
CPU_65C02
CPU_65816
CPU_SUNPLUS
CPU_SWEET16
CPU_HUC6280
is defined. These constants may be used to determine the exact type of the currently enabled CPU. In addition to that, for each CPU instruction set, another constant is defined:
CPU_ISET_6502
CPU_ISET_65SC02
CPU_ISET_65C02
CPU_ISET_65816
CPU_ISET_SUNPLUS
CPU_ISET_SWEET16
CPU_ISET_HUC6280
The value read from the
.CPU
pseudo variable may
be checked with
.BITAND
to determine if the
currently enabled CPU supports a specific instruction set. For example the
65C02 supports all instructions of the 65SC02 CPU, so it has the
CPU_ISET_65SC02
bit set in addition to its native CPU_ISET_65C02
bit. Using
.if (.cpu .bitand CPU_ISET_65SC02)
lda (sp)
.else
ldy #$00
lda (sp),y
.endif
it is possible to determine if the
lda (sp)
instruction is supported, which is the case for the 65SC02, 65C02 and 65816 CPUs (the latter two are upwards compatible to the 65SC02).