![kueller](/assets/img/avatar_default.png)
git-svn-id: svn://svn.compuextreme.de/Viitor/V961/Viitor_cc65@4236 504e572c-2e33-0410-9681-be2bf7408885
169 lines
4.4 KiB
HTML
169 lines
4.4 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.20">
|
|
<TITLE>ca65 Users Guide: Macro packages</TITLE>
|
|
<LINK HREF="ca65-13.html" REL=next>
|
|
<LINK HREF="ca65-11.html" REL=previous>
|
|
<LINK HREF="ca65.html#toc12" REL=contents>
|
|
</HEAD>
|
|
<BODY>
|
|
<A HREF="ca65-13.html">Next</A>
|
|
<A HREF="ca65-11.html">Previous</A>
|
|
<A HREF="ca65.html#toc12">Contents</A>
|
|
<HR>
|
|
<H2><A NAME="macropackages"></A> <A NAME="s12">12.</A> <A HREF="ca65.html#toc12">Macro packages</A></H2>
|
|
|
|
|
|
<P>Using the <CODE>
|
|
<A HREF="ca65-10.html#.MACPACK">.MACPACK</A></CODE> directive, predefined
|
|
macro packages may be included with just one command. Available macro packages
|
|
are:</P>
|
|
|
|
|
|
<H2><A NAME="ss12.1">12.1</A> <A HREF="ca65.html#toc12.1"><CODE>.MACPACK generic</CODE></A>
|
|
</H2>
|
|
|
|
|
|
<P>This macro package defines macros that are useful in almost any program.
|
|
Currently, two macros are defined:</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
.macro add Arg
|
|
clc
|
|
adc Arg
|
|
.endmacro
|
|
|
|
.macro sub Arg
|
|
sec
|
|
sbc Arg
|
|
.endmacro
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
|
|
|
|
<H2><A NAME="ss12.2">12.2</A> <A HREF="ca65.html#toc12.2"><CODE>.MACPACK longbranch</CODE></A>
|
|
</H2>
|
|
|
|
|
|
<P>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 "<CODE>jeq</CODE>" macro, the other macros are built using the same
|
|
scheme:</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
.macro jeq Target
|
|
.if .def(Target) .and ((*+2)-(Target) <= 127)
|
|
beq Target
|
|
.else
|
|
bne *+5
|
|
jmp Target
|
|
.endif
|
|
.endmacro
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>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.</P>
|
|
<P>The package defines the following macros:</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
jeq, jne, jmi, jpl, jcs, jcc, jvs, jvc
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
|
|
|
|
|
|
<H2><A NAME="ss12.3">12.3</A> <A HREF="ca65.html#toc12.3"><CODE>.MACPACK cbm</CODE></A>
|
|
</H2>
|
|
|
|
|
|
<P>The cbm macro package will define a macro named <CODE>scrcode</CODE>. It takes a
|
|
string as argument and places this string into memory translated into screen
|
|
codes.</P>
|
|
|
|
|
|
<H2><A NAME="ss12.4">12.4</A> <A HREF="ca65.html#toc12.4"><CODE>.MACPACK cpu</CODE></A>
|
|
</H2>
|
|
|
|
|
|
<P>This macro package does not define any macros but constants used to examine
|
|
the value read from the <CODE>
|
|
<A HREF="ca65-8.html#.CPU">.CPU</A></CODE> pseudo variable. For
|
|
each supported CPU a constant similar to</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
CPU_6502
|
|
CPU_65SC02
|
|
CPU_65C02
|
|
CPU_65816
|
|
CPU_SUNPLUS
|
|
CPU_SWEET16
|
|
CPU_HUC6280
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>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:</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
CPU_ISET_6502
|
|
CPU_ISET_65SC02
|
|
CPU_ISET_65C02
|
|
CPU_ISET_65816
|
|
CPU_ISET_SUNPLUS
|
|
CPU_ISET_SWEET16
|
|
CPU_ISET_HUC6280
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>The value read from the <CODE>
|
|
<A HREF="ca65-8.html#.CPU">.CPU</A></CODE> pseudo variable may
|
|
be checked with <CODE>
|
|
<A HREF="ca65-4.html#operators">.BITAND</A></CODE> 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
|
|
<CODE>CPU_ISET_65SC02</CODE> bit set in addition to its native <CODE>CPU_ISET_65C02</CODE>
|
|
bit. Using</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
|
lda (sp)
|
|
.else
|
|
ldy #$00
|
|
lda (sp),y
|
|
.endif
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>it is possible to determine if the</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
lda (sp)
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>instruction is supported, which is the case for the 65SC02, 65C02 and 65816
|
|
CPUs (the latter two are upwards compatible to the 65SC02).</P>
|
|
|
|
|
|
|
|
<HR>
|
|
<A HREF="ca65-13.html">Next</A>
|
|
<A HREF="ca65-11.html">Previous</A>
|
|
<A HREF="ca65.html#toc12">Contents</A>
|
|
</BODY>
|
|
</HTML>
|