⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ca65-10.html

📁 cc65 的编译器文档
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!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: Control commands</TITLE> <LINK HREF="ca65-11.html" REL=next> <LINK HREF="ca65-9.html" REL=previous> <LINK HREF="ca65.html#toc10" REL=contents></HEAD><BODY><A HREF="ca65-11.html">Next</A><A HREF="ca65-9.html">Previous</A><A HREF="ca65.html#toc10">Contents</A><HR><H2><A NAME="control-commands"></A> <A NAME="s10">10.</A> <A HREF="ca65.html#toc10">Control commands</A></H2><P>Here's a list of all control commands and a description, what they do:</P><H2><A NAME=".A16"></A> <A NAME="ss10.1">10.1</A> <A HREF="ca65.html#toc10.1"><CODE>.A16</CODE></A></H2><P>Valid only in 65816 mode. Switch the accumulator to 16 bit.</P><P>Note: This command will not emit any code, it will tell the assembler tocreate 16 bit operands for immediate accumulator adressing mode.</P><P>See also: <CODE><A HREF="#.SMART">.SMART</A></CODE></P><H2><A NAME=".A8"></A> <A NAME="ss10.2">10.2</A> <A HREF="ca65.html#toc10.2"><CODE>.A8</CODE></A></H2><P>Valid only in 65816 mode. Switch the accumulator to 8 bit.</P><P>Note: This command will not emit any code, it will tell the assembler tocreate 8 bit operands for immediate accu adressing mode.</P><P>See also: <CODE><A HREF="#.SMART">.SMART</A></CODE></P><H2><A NAME=".ADDR"></A> <A NAME="ss10.3">10.3</A> <A HREF="ca65.html#toc10.3"><CODE>.ADDR</CODE></A></H2><P>Define word sized data. In 6502 mode, this is an alias for <CODE>.WORD</CODE> andmay be used for better readability if the data words are address values. In65816 mode, the address is forced to be 16 bit wide to fit into the currentsegment. See also <CODE><A HREF="#.FARADDR">.FARADDR</A></CODE>. The commandmust be followed by a sequence of (not necessarily constant) expressions.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        .addr   $0D00, $AF13, _Clear  </PRE></CODE></BLOCKQUOTE></P><P>See: <CODE><A HREF="#.FARADDR">.FARADDR</A></CODE>, <CODE><A HREF="#.WORD">.WORD</A></CODE></P><H2><A NAME=".ALIGN"></A> <A NAME="ss10.4">10.4</A> <A HREF="ca65.html#toc10.4"><CODE>.ALIGN</CODE></A></H2><P>Align data to a given boundary. The command expects a constant integerargument that must be a power of two, plus an optional second argumentin byte range. If there is a second argument, it is used as fill value,otherwise the value defined in the linker configuration file is used(the default for this value is zero).</P><P>Since alignment depends on the base address of the module, you mustgive the same (or a greater) alignment for the segment when linking.The linker will give you a warning, if you don't do that.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        .align  256  </PRE></CODE></BLOCKQUOTE></P><H2><A NAME=".ASCIIZ"></A> <A NAME="ss10.5">10.5</A> <A HREF="ca65.html#toc10.5"><CODE>.ASCIIZ</CODE></A></H2><P>Define a string with a trailing zero.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        Msg:    .asciiz "Hello world"  </PRE></CODE></BLOCKQUOTE></P><P>This will put the string "Hello world" followed by a binary zero intothe current segment. There may be more strings separated by commas, butthe binary zero is only appended once (after the last one).</P><H2><A NAME=".ASSERT"></A> <A NAME="ss10.6">10.6</A> <A HREF="ca65.html#toc10.6"><CODE>.ASSERT</CODE></A></H2><P>Add an assertion. The command is followed by an expression, an actionspecifier and a message that is output in case the assertion fails. Theaction specifier may be one of <CODE>warning</CODE> or <CODE>error</CODE>. The assertionis passed to the linker and will be evaluated when segment placement hasbeen done.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        .assert         * = $8000, error, "Code not at $8000"  </PRE></CODE></BLOCKQUOTE></P><P>The example assertion will check that the current location is at $8000,when the output file is written, and abort with an error if this is notthe case. More complex expressions are possible. The action specifier<CODE>warning</CODE> outputs a warning, while the <CODE>error</CODE> specifier outputsan error message. In the latter case, generation if the output file issuppressed.</P><H2><A NAME=".AUTOIMPORT"></A> <A NAME="ss10.7">10.7</A> <A HREF="ca65.html#toc10.7"><CODE>.AUTOIMPORT</CODE></A></H2><P>Is followed by a plus or a minus character. When switched on (using a+), undefined symbols are automatically marked as import instead ofgiving errors. When switched off (which is the default so this does notmake much sense), this does not happen and an error message isdisplayed. The state of the autoimport flag is evaluated when thecomplete source was translated, before outputing actual code, so it is<EM>not</EM> possible to switch this feature on or off for separate sectionsof code. The last setting is used for all symbols.</P><P>You should probably not use this switch because it delays errormessages about undefined symbols until the link stage. The cc65compiler (which is supposed to produce correct assembler code in allcircumstances, something which is not true for most assemblerprogrammers) will insert this command to avoid importing each and everyroutine from the runtime library.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        .autoimport     +       ; Switch on auto import  </PRE></CODE></BLOCKQUOTE></P><H2><A NAME=".BSS"></A> <A NAME="ss10.8">10.8</A> <A HREF="ca65.html#toc10.8"><CODE>.BSS</CODE></A></H2><P>Switch to the BSS segment. The name of the BSS segment is always "BSS",so this is a shortcut for</P><P><BLOCKQUOTE><CODE><PRE>        .segment  "BSS"  </PRE></CODE></BLOCKQUOTE></P><P>See also the <CODE><A HREF="#.SEGMENT">.SEGMENT</A></CODE> command.</P><H2><A NAME=".BYTE"></A> <A NAME="ss10.9">10.9</A> <A HREF="ca65.html#toc10.9"><CODE>.BYT, .BYTE</CODE></A></H2><P>Define byte sized data. Must be followed by a sequence of (byte ranged)expressions or strings.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        .byte   "Hello "        .byt    "world", $0D, $00  </PRE></CODE></BLOCKQUOTE></P><H2><A NAME=".CASE"></A> <A NAME="ss10.10">10.10</A> <A HREF="ca65.html#toc10.10"><CODE>.CASE</CODE></A></H2><P>Switch on or off case sensitivity on identifiers. The default is off(that is, identifiers are case sensitive), but may be changed by the-i switch on the command line.The command must be followed by a '+' or '-' character to switch theoption on or off respectively.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        .case   -               ; Identifiers are not case sensitive  </PRE></CODE></BLOCKQUOTE></P><H2><A NAME=".CHARMAP"></A> <A NAME="ss10.11">10.11</A> <A HREF="ca65.html#toc10.11"><CODE>.CHARMAP</CODE></A></H2><P>Apply a custom mapping for characters. The command is followed by twonumbers in the range 1..255. The first one is the index of the sourcecharacter, the second one is the mapping. The mapping applies to allcharacter and string constants when they generate output, and overridesa mapping table specified with the <CODE><A HREF="ca65-2.html#option-t">-t</A></CODE>command line switch.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        .charmap        $41, $61        ; Map 'A' to 'a'  </PRE></CODE></BLOCKQUOTE></P><H2><A NAME=".CODE"></A> <A NAME="ss10.12">10.12</A> <A HREF="ca65.html#toc10.12"><CODE>.CODE</CODE></A></H2><P>Switch to the CODE segment. The name of the CODE segment is always"CODE", so this is a shortcut for</P><P><BLOCKQUOTE><CODE><PRE>        .segment  "CODE"  </PRE></CODE></BLOCKQUOTE></P><P>See also the <CODE><A HREF="#.SEGMENT">.SEGMENT</A></CODE> command.</P><H2><A NAME=".CONDES"></A> <A NAME="ss10.13">10.13</A> <A HREF="ca65.html#toc10.13"><CODE>.CONDES</CODE></A></H2><P>Export a symbol and mark it in a special way. The linker is able to buildtables of all such symbols. This may be used to automatically create a listof functions needed to initialize linked library modules.</P><P>Note: The linker has a feature to build a table of marked routines, but itis your code that must call these routines, so just declaring a symbol with<CODE>.CONDES</CODE> does nothing by itself.</P><P>All symbols are exported as an absolute (16 bit) symbol. You don't need touse an additional <CODE><A HREF="#.EXPORT">.EXPORT</A></CODE> statement, thisis implied by <CODE>.CONDES</CODE>.</P><P><CODE>.CONDES</CODE> is followed by the type, which may be <CODE>constructor</CODE>,<CODE>destructor</CODE> or a numeric value between 0 and 6 (where 0 is the same asspecifiying <CODE>constructor</CODE> and 1 is equal to specifying <CODE>destructor</CODE>).The <CODE><A HREF="#.CONSTRUCTOR">.CONSTRUCTOR</A></CODE> and <CODE><A HREF="#.DESTRUCTOR">.DESTRUCTOR</A></CODE> commands are actually shortcutsfor <CODE>.CONDES</CODE> with a type of <CODE>constructor</CODE> resp. <CODE>destructor</CODE>.</P><P>After the type, an optional priority may be specified. Higher numeric valuesmean higher priority. If no priority is given, the default priority of 7 isused. Be careful when assigning priorities to your own module constructorsso they won't interfere with the ones in the cc65 library.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        .condes         ModuleInit, constructor        .condes         ModInit, 0, 16  </PRE></CODE></BLOCKQUOTE></P><P>See the <CODE><A HREF="#.CONSTRUCTOR">.CONSTRUCTOR</A></CODE> and <CODE><A HREF="#.DESTRUCTOR">.DESTRUCTOR</A></CODE> commands and the separate section<A HREF="ca65-14.html#condes">Module constructors/destructors</A> explaining thefeature in more detail.</P><H2><A NAME=".CONSTRUCTOR"></A> <A NAME="ss10.14">10.14</A> <A HREF="ca65.html#toc10.14"><CODE>.CONSTRUCTOR</CODE></A></H2><P>Export a symbol and mark it as a module constructor. This may be usedtogether with the linker to build a table of constructor subroutines thatare called by the startup code.</P><P>Note: The linker has a feature to build a table of marked routines, but itis your code that must call these routines, so just declaring a symbol asconstructor does nothing by itself.</P><P>A constructor is always exported as an absolute (16 bit) symbol. You don'tneed to use an additional <CODE>.export</CODE> statement, this is implied by<CODE>.constructor</CODE>. It may have an optional priority that is separated by acomma. Higher numeric values mean a higher priority. If no priority isgiven, the default priority of 7 is used. Be careful when assigningpriorities to your own module constructors so they won't interfere with theones in the cc65 library.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        .constructor    ModuleInit        .constructor    ModInit, 16  </PRE></CODE></BLOCKQUOTE></P><P>See the <CODE><A HREF="#.CONDES">.CONDES</A></CODE> and <CODE><A HREF="#.DESTRUCTOR">.DESTRUCTOR</A></CODE> commands and the separate section<A HREF="ca65-14.html#condes">Module constructors/destructors</A> explaining thefeature in more detail.</P><H2><A NAME=".DATA"></A> <A NAME="ss10.15">10.15</A> <A HREF="ca65.html#toc10.15"><CODE>.DATA</CODE></A></H2><P>Switch to the DATA segment. The name of the DATA segment is always"DATA", so this is a shortcut for</P><P><BLOCKQUOTE><CODE><PRE>        .segment  "DATA"  </PRE></CODE></BLOCKQUOTE></P><P>See also the <CODE><A HREF="#.SEGMENT">.SEGMENT</A></CODE> command.</P><H2><A NAME=".DBYT"></A> <A NAME="ss10.16">10.16</A> <A HREF="ca65.html#toc10.16"><CODE>.DBYT</CODE></A></H2><P>Define word sized data with the hi and lo bytes swapped (use <CODE>.WORD</CODE> tocreate word sized data in native 65XX format). Must be followed by asequence of (word ranged) expressions.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE>        .dbyt   $1234, $4512  </PRE></CODE></BLOCKQUOTE></P><P>This will emit the bytes</P><P><BLOCKQUOTE><CODE><PRE>        $12 $34 $45 $12  </PRE></CODE></BLOCKQUOTE></P><P>into the current segment in that order.</P><H2><A NAME=".DEBUGINFO"></A> <A NAME="ss10.17">10.17</A> <A HREF="ca65.html#toc10.17"><CODE>.DEBUGINFO</CODE></A></H2><P>Switch on or off debug info generation. The default is off (that is,the object file will not contain debug infos), but may be changed by the-g switch on the command line.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -