📄 ca65-10.html
字号:
<H2><A NAME=".PUSHSEG"></A> <A NAME="ss10.77">10.77</A> <A HREF="ca65.html#toc10.77"><CODE>.PUSHSEG</CODE></A></H2><P>Push the currently active segment onto a stack. The entries on the stackinclude the name of the segment and the segment type. The stack has a sizeof 16 entries.</P><P><CODE>.PUSHSEG</CODE> allows together with <CODE><A HREF="#.POPSEG">.POPSEG</A></CODE>to switch to another segment and to restore the old segment later, withouteven knowing the name and type of the current segment.</P><P>The assembler will print an error message if the segment stack is alreadyfull, when this command is issued.</P><P>See: <CODE><A HREF="#.POPSEG">.POPSEG</A></CODE></P><H2><A NAME=".REPEAT"></A> <A NAME="ss10.78">10.78</A> <A HREF="ca65.html#toc10.78"><CODE>.REPEAT</CODE></A></H2><P>Repeat all commands between <CODE>.REPEAT</CODE> and <CODE><A HREF="#.ENDREPEAT">.ENDREPEAT</A></CODE> constant number of times. The command is followed bya constant expression that tells how many times the commands in the bodyshould get repeated. Optionally, a comma and an identifier may be specified.If this identifier is found in the body of the repeat statement, it isreplaced by the current repeat count (starting with zero for the first timethe body is repeated).</P><P><CODE>.REPEAT</CODE> statements may be nested. If you use the same repeat countidentifier for a nested <CODE>.REPEAT</CODE> statement, the one from the innerlevel will be used, not the one from the outer level.</P><P>Example:</P><P>The following macro will emit a string that is "encrypted" in that allcharacters of the string are XORed by the value $55.</P><P><BLOCKQUOTE><CODE><PRE> .macro Crypt Arg .repeat .strlen(Arg), I .byte .strat(Arg, I) .xor $55 .endrep .endmacro </PRE></CODE></BLOCKQUOTE></P><P>See: <CODE><A HREF="#.ENDREPEAT">.ENDREPEAT</A></CODE></P><H2><A NAME=".RELOC"></A> <A NAME="ss10.79">10.79</A> <A HREF="ca65.html#toc10.79"><CODE>.RELOC</CODE></A></H2><P>Switch back to relocatable mode. See the <CODE><A HREF="#.ORG">.ORG</A></CODE> command.</P><H2><A NAME=".RES"></A> <A NAME="ss10.80">10.80</A> <A HREF="ca65.html#toc10.80"><CODE>.RES</CODE></A></H2><P>Reserve storage. The command is followed by one or two constantexpressions. The first one is mandatory and defines, how many bytes ofstorage should be defined. The second, optional expression must by aconstant byte value that will be used as value of the data. If thereis no fill value given, the linker will use the value defined in thelinker configuration file (default: zero).</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE> ; Reserve 12 bytes of memory with value $AA .res 12, $AA </PRE></CODE></BLOCKQUOTE></P><H2><A NAME=".RODATA"></A> <A NAME="ss10.81">10.81</A> <A HREF="ca65.html#toc10.81"><CODE>.RODATA</CODE></A></H2><P>Switch to the RODATA segment. The name of the RODATA segment is always"RODATA", so this is a shortcut for</P><P><BLOCKQUOTE><CODE><PRE> .segment "RODATA" </PRE></CODE></BLOCKQUOTE></P><P>The RODATA segment is a segment that is used by the compiler forreadonly data like string constants.</P><P>See also the <CODE><A HREF="#.SEGMENT">.SEGMENT</A></CODE> command.</P><H2><A NAME=".SCOPE"></A> <A NAME="ss10.82">10.82</A> <A HREF="ca65.html#toc10.82"><CODE>.SCOPE</CODE></A></H2><P>Start a nested lexical level with the given name. All new symbols from nowon are in the local lexical level and are accessible from outside only via<A HREF="ca65-6.html#scopesyntax">explicit scope specification</A>. Symbols definedoutside this local level may be accessed as long as their names are not usedfor new symbols inside the level. Symbols names in other lexical levels donot clash, so you may use the same names for identifiers. The lexical levelends when the <CODE><A HREF="#.ENDSCOPE">.ENDSCOPE</A></CODE> command isread. Lexical levels may be nested up to a depth of 16 (this is anartificial limit to protect against errors in the source).</P><P>Note: Macro names are always in the global level and in a separate namespace. There is no special reason for this, it's just that I've neverhad any need for local macro definitions.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE> .scope Error ; Start new scope named Error None = 0 ; No error File = 1 ; File error Parse = 2 ; Parse error .endproc ; Close lexical level ... lda #Error::File ; Use symbol from scope Error </PRE></CODE></BLOCKQUOTE></P><P>See: <CODE><A HREF="#.ENDSCOPE">.ENDSCOPE</A></CODE> and <CODE><A HREF="#.PROC">.PROC</A></CODE></P><H2><A NAME=".SEGMENT"></A> <A NAME="ss10.83">10.83</A> <A HREF="ca65.html#toc10.83"><CODE>.SEGMENT</CODE></A></H2><P>Switch to another segment. Code and data is always emitted into asegment, that is, a named section of data. The default segment is"CODE". There may be up to 254 different segments per object file(and up to 65534 per executable). There are shortcut commands forthe most common segments ("CODE", "DATA" and "BSS").</P><P>The command is followed by a string containing the segment name (thereare some constraints for the name - as a rule of thumb use only thosesegment names that would also be valid identifiers). There may also bean optional attribute separated by a colon. Valid attributes are"<CODE>zeropage</CODE>" and "<CODE>absolute</CODE>".</P><P>When specifying a segment for the first time, "absolute" is thedefault. For all other uses, the attribute specified the first timeis the default.</P><P>"absolute" means that this is a segment with absolute addressing. Thatis, the segment will reside somewhere in core memory outside the zeropage. "zeropage" means the opposite: The segment will be placed in thezero page and direct (short) addressing is possible for data in thissegment.</P><P>Beware: Only labels in a segment with the zeropage attribute are markedas reachable by short addressing. The `*' (PC counter) operator willwork as in other segments and will create absolute variable values.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE> .segment "ROM2" ; Switch to ROM2 segment .segment "ZP2": zeropage ; New direct segment .segment "ZP2" ; Ok, will use last attribute .segment "ZP2": absolute ; Error, redecl mismatch </PRE></CODE></BLOCKQUOTE></P><P>See: <CODE><A HREF="#.BSS">.BSS</A></CODE>, <CODE><A HREF="#.CODE">.CODE</A></CODE>, <CODE><A HREF="#.DATA">.DATA</A></CODE> and <CODE><A HREF="#.RODATA">.RODATA</A></CODE></P><H2><A NAME=".SETCPU"></A> <A NAME="ss10.84">10.84</A> <A HREF="ca65.html#toc10.84"><CODE>.SETCPU</CODE></A></H2><P>Switch the CPU instruction set. The command is followed by a string thatspecifies the CPU. Possible values are those that can also be supplied tothe <CODE><A HREF="ca65-2.html#option--cpu">--cpu</A></CODE> command line option,namely: 6502, 65SC02, 65C02, 65816 and sunplus. Please note that supportfor the sunplus CPU is not available in the freeware version, because theinstruction set of the sunplus CPU is "proprietary and confidential".</P><P>See: <CODE><A HREF="ca65-8.html#.CPU">.CPU</A></CODE>,<CODE><A HREF="#.IFP02">.IFP02</A></CODE>,<CODE><A HREF="#.IFP816">.IFP816</A></CODE>,<CODE><A HREF="#.IFPC02">.IFPC02</A></CODE>,<CODE><A HREF="#.IFPSC02">.IFPSC02</A></CODE>,<CODE><A HREF="#.P02">.P02</A></CODE>,<CODE><A HREF="#.P816">.P816</A></CODE>,<CODE><A HREF="#.PC02">.PC02</A></CODE>,<CODE><A HREF="#.PSC02">.PSC02</A></CODE></P><H2><A NAME=".SMART"></A> <A NAME="ss10.85">10.85</A> <A HREF="ca65.html#toc10.85"><CODE>.SMART</CODE></A></H2><P>Switch on or off smart mode. The command must be followed by a '+' or'-' character to switch the option on or off respectively. The defaultis off (that is, the assembler doesn't try to be smart), but thisdefault may be changed by the -s switch on the command line.</P><P>In smart mode the assembler will do the following:</P><P><UL><LI>Track usage of the <CODE>REP</CODE> and <CODE>SEP</CODE> instructions in 65816 modeand update the operand sizes accordingly. If the operand of such aninstruction cannot be evaluated by the assembler (for example, becausethe operand is an imported symbol), a warning is issued. Beware: Sincethe assembler cannot trace the execution flow this may lead to falseresults in some cases. If in doubt, use the <CODE>.Inn</CODE> and <CODE>.Ann</CODE>instructions to tell the assembler about the current settings.</LI><LI>In 65816 mode, replace a <CODE>RTS</CODE> instruction by <CODE>RTL</CODE> if it isused within a procedure declared as <CODE>far</CODE>, or if the procedure hasno explicit address specification, but it is <CODE>far</CODE> because of thememory model used.</LI></UL></P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE> .smart ; Be smart .smart - ; Stop being smart </PRE></CODE></BLOCKQUOTE></P><P>See: <CODE><A HREF="#.A16">.A16</A></CODE>,<CODE><A HREF="#.A8">.A8</A></CODE>,<CODE><A HREF="#.I16">.I16</A></CODE>,<CODE><A HREF="#.I8">.I8</A></CODE></P><H2><A NAME=".STRUCT"></A> <A NAME="ss10.86">10.86</A> <A HREF="ca65.html#toc10.86"><CODE>.STRUCT</CODE></A></H2><P>Starts a struct definition. Structs are covered in a separate section named<A HREF="ca65-13.html#structs">"Structs and unions"</A>.</P><P>See: <CODE><A HREF="#.ENDSTRUCT">.ENDSTRUCT</A></CODE></P><H2><A NAME=".SUNPLUS"></A> <A NAME="ss10.87">10.87</A> <A HREF="ca65.html#toc10.87"><CODE>.SUNPLUS</CODE></A></H2><P>Enable the SunPlus instructions set. This command will not work in thefreeware version of the assembler, because the instruction set is"proprietary and confidential".</P><P>See: <CODE><A HREF="#.P02">.P02</A></CODE>, <CODE><A HREF="#.PSC02">.PSC02</A></CODE>, <CODE><A HREF="#.PC02">.PC02</A></CODE>, and<CODE><A HREF="#.P816">.P816</A></CODE></P><H2><A NAME=".TAG"></A> <A NAME="ss10.88">10.88</A> <A HREF="ca65.html#toc10.88"><CODE>.TAG</CODE></A></H2><P>Allocate space for a struct or union.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE> .struct Point xcoord .word ycoord .word .endstruct .bss .tag Point ; Allocate 4 bytes </PRE></CODE></BLOCKQUOTE></P><H2><A NAME=".WARNING"></A> <A NAME="ss10.89">10.89</A> <A HREF="ca65.html#toc10.89"><CODE>.WARNING</CODE></A></H2><P>Force an assembly warning. The assembler will output a warning messagepreceeded by "User warning". This warning will always be output, even ifother warnings are disabled with the <CODE><A HREF="ca65-2.html#option-W">-W0</A></CODE>command line option.</P><P>This command may be used to output possible problems when assemblingthe source file.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE> .macro jne target .local L1 .ifndef target .warning "Forward jump in jne, cannot optimize!" beq L1 jmp target L1: .else ... .endif .endmacro </PRE></CODE></BLOCKQUOTE></P><P>See also the <CODE><A HREF="#.ERROR">.ERROR</A></CODE> and <CODE><A HREF="#.OUT">.OUT</A></CODE> directives.</P><H2><A NAME=".WORD"></A> <A NAME="ss10.90">10.90</A> <A HREF="ca65.html#toc10.90"><CODE>.WORD</CODE></A></H2><P>Define word sized data. Must be followed by a sequence of (word ranged,but not necessarily constant) expressions.</P><P>Example:</P><P><BLOCKQUOTE><CODE><PRE> .word $0D00, $AF13, _Clear </PRE></CODE></BLOCKQUOTE></P><H2><A NAME=".ZEROPAGE"></A> <A NAME="ss10.91">10.91</A> <A HREF="ca65.html#toc10.91"><CODE>.ZEROPAGE</CODE></A></H2><P>Switch to the ZEROPAGE segment and mark it as direct (zeropage) segment.The name of the ZEROPAGE segment is always "ZEROPAGE", so this is ashortcut for</P><P><BLOCKQUOTE><CODE><PRE> .segment "ZEROPAGE": zeropage </PRE></CODE></BLOCKQUOTE></P><P>Because of the "zeropage" attribute, labels declared in this segment areaddressed using direct addressing mode if possible. You <EM>must</EM> instructthe linker to place this segment somewhere in the address range 0..$FFotherwise you will get errors.</P><P>See: <CODE><A HREF="#.SEGMENT">.SEGMENT</A></CODE></P><HR><A HREF="ca65-11.html">Next</A><A HREF="ca65-9.html">Previous</A><A HREF="ca65.html#toc10">Contents</A></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -