?? ca65-12.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, predefinedmacro packages may be included with just one command. Available macro packagesare:</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 theshort counterpart but with the 'b' replaced by a 'j'. Here is a sampledefinition for the "<CODE>jeq</CODE>" macro, the other macros are built using the samescheme:</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 (backjump) and is reachable with a short jump. Otherwise the macro expands to aconditional branch with the branch condition inverted, followed by an absolutejump 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 astring as argument and places this string into memory translated into screencodes.</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 examinethe value read from the <CODE><A HREF="ca65-8.html#.CPU">.CPU</A></CODE> pseudo variable. Foreach supported CPU a constant similar to</P><P><BLOCKQUOTE><CODE><PRE> CPU_6502 CPU_65SC02 CPU_65C02 CPU_65816 CPU_SUNPLUS</PRE></CODE></BLOCKQUOTE></P><P>is defined. These constants may be used to determine the exact type of thecurrently 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</PRE></CODE></BLOCKQUOTE></P><P>The value read from the <CODE><A HREF="ca65-8.html#.CPU">.CPU</A></CODE> pseudo variable maybe checked with <CODE><A HREF="ca65-4.html#operators">.BITAND</A></CODE> to determine if thecurrently enabled CPU supports a specific instruction set. For example the65C02 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 65816CPUs (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>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -