diff --git a/doc/Makefile b/doc/Makefile index 405c261a3..4bc6cf472 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -50,7 +50,7 @@ clean: rm -f *~ zap: clean - rm -f $(TXT) $(HTML) $(INFO) $(DVI) *.html *.info-* + rm -f $(TXT) $(HTML) $(INFO) $(DVI) *.html *.info-* *.man # ------------------------------------------------------------------------------ # Make the dependencies diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 5d1a3b8af..4a858c7ba 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -348,7 +348,7 @@ Available operators sorted by precedence: Op Description Precedence ------------------------------------------------------------------- - .CONCAT Builtin function 0 + .CONCAT Builtin function 0 .LEFT Builtin function 0 .MID Builtin function 0 .RIGHT Builtin function 0 @@ -369,8 +369,8 @@ Available operators sorted by precedence: - Unary minus 1 ~ Unary bitwise not 1 .BITNOT Unary bitwise not 1 - < Low byte operator 1 - > High byte operator 1 + < Low byte operator 1 + > High byte operator 1 * Multiplication 2 / Division 2 @@ -526,7 +526,7 @@ use symbols and labels, giving a lot of flexibility. prefer the "cheap" local labels). Nevertheless, unnamed labels are convenient in some situations, so it's your decision. - - Using macros to define labels and constants + -.A16 +.A16 Valid only in 65816 mode. Switch the accumulator to 16 bit. @@ -577,7 +577,7 @@ Here's a list of all control commands and a description, what they do: See also: .A8 +.A8 Valid only in 65816 mode. Switch the accumulator to 8 bit. @@ -587,7 +587,7 @@ Here's a list of all control commands and a description, what they do: See also: .ADDR +.ADDR Define word sized data. In 6502 mode, this is an alias for -.ALIGN +.ALIGN Align data to a given boundary. The command expects a constant integer argument that must be a power of two, plus an optional second argument @@ -621,7 +621,7 @@ Here's a list of all control commands and a description, what they do: -.ASCIIZ +.ASCIIZ Define a string with a trailing zero. @@ -636,7 +636,7 @@ Here's a list of all control commands and a description, what they do: the binary zero is only appended once (after the last one). -.AUTOIMPORT +.AUTOIMPORT Is followd by a plus or a minus character. When switched on (using a +), undefined symbols are automatically marked as import instead of @@ -661,7 +661,7 @@ Here's a list of all control commands and a description, what they do: -.BLANK +.BLANK Builtin function. The function evaluates its argument in braces and yields "false" if the argument is non blank (there is an argument), and @@ -673,7 +673,7 @@ Here's a list of all control commands and a description, what they do: -.BSS +.BSS Switch to the BSS segment. The name of the BSS segment is always "BSS", so this is a shortcut for @@ -685,7 +685,7 @@ Here's a list of all control commands and a description, what they do: See also the .BYTE +.BYTE Define byte sized data. Must be followed by a sequence of (byte ranged) expressions or strings. @@ -697,7 +697,7 @@ Here's a list of all control commands and a description, what they do: -.CASE +.CASE Switch on or off case sensitivity on identifiers. The default is off (that is, identifiers are case sensitive), but may be changed by the @@ -712,7 +712,7 @@ Here's a list of all control commands and a description, what they do: -.CODE +.CODE Switch to the CODE segment. The name of the CODE segment is always "CODE", so this is a shortcut for @@ -724,7 +724,7 @@ Here's a list of all control commands and a description, what they do: See also the .CONCAT +.CONCAT Builtin function. The function allows to concatenate a list of string constants separated by commas. The result is a string constant that @@ -746,7 +746,7 @@ Here's a list of all control commands and a description, what they do: -.CONST +.CONST Builtin function. The function evaluates its argument in braces and yields "true" if the argument is a constant expression (that is, an @@ -758,7 +758,7 @@ Here's a list of all control commands and a description, what they do: -.CPU +.CPU Reading this pseudo variable will give a constant integer value that tells which instruction set is currently enabled. Possible values are: @@ -788,7 +788,7 @@ Here's a list of all control commands and a description, what they do: -.DATA +.DATA Switch to the DATA segment. The name of the DATA segment is always "DATA", so this is a shortcut for @@ -800,7 +800,7 @@ Here's a list of all control commands and a description, what they do: See also the .DBYT +.DBYT Define word sized data with the hi and lo bytes swapped (use .DEBUGINFO +.DEBUGINFO 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 @@ -836,7 +836,7 @@ Here's a list of all control commands and a description, what they do: -.DEFINE +.DEFINE Start a define style macro definition. The command is followed by an identifier (the macro name) and optionally by a list of formal arguments @@ -844,7 +844,7 @@ Here's a list of all control commands and a description, what they do: See separate section about macros. -.DEF, .DEFINED +.DEF, .DEFINED Builtin function. The function expects an identifier as argument in braces. The argument is evaluated, and the function yields "true" if the @@ -857,7 +857,7 @@ Here's a list of all control commands and a description, what they do: -.DWORD +.DWORD Define dword sized data (4 bytes) Must be followed by a sequence of expressions. @@ -869,38 +869,43 @@ Here's a list of all control commands and a description, what they do: -.ELSE +.ELSE Conditional assembly: Reverse the current condition. -.ELSEIF +.ELSEIF Conditional assembly: Reverse current condition and test a new one. -.END +.END Forced end of assembly. Assembly stops at this point, even if the command is read from an include file. -.ENDIF +.ENDIF Conditional assembly: Close a .ENDMAC, .ENDMACRO +.ENDMAC, .ENDMACRO End of macro definition (see separate section). -.ENDPROC +.ENDPROC End of local lexical level (see .ERROR +.ENDREP, .ENDREPEAT + + End a .ERROR Force an assembly error. The assembler will output an error message preceeded by "User error" and will .EXITMAC, .EXITMACRO +.EXITMAC, .EXITMACRO Abort a macro expansion immidiately. This command is often useful in recursive macros. See separate chapter about macros. -.EXPORT +.EXPORT Make symbols accessible from other modules. Must be followed by a comma separated list of symbols to export. @@ -941,7 +946,7 @@ Here's a list of all control commands and a description, what they do: -.EXPORTZP +.EXPORTZP Make symbols accessible from other modules. Must be followed by a comma separated list of symbols to export. The exported symbols are explicitly @@ -954,7 +959,7 @@ Here's a list of all control commands and a description, what they do: -.FARADDR +.FARADDR Define far (24 bit) address data. The command must be followed by a sequence of (not necessarily constant) expressions. @@ -966,7 +971,7 @@ Here's a list of all control commands and a description, what they do: -.FEATURE +.FEATURE This directive may be used to enable one or more compatibility features of the assembler. While the use of - dollar_is_pc + >dollar_is_pc The dollar sign may be used as an alias for the star (`*'), which gives the value of the current PC in expressions. Note: Assignment to the pseudo variable is not allowed. - labels_without_colons + >labels_without_colons Allow labels without a trailing colon. These labels are only accepted, if they start at the beginning of a line (no leading white space). - loose_string_term + >loose_string_term Accept single quotes as well as double quotes as terminators for string constants. - at_in_identifiers + >at_in_identifiers Accept the at character (`@') as a valid character in identifiers. The at character is not allowed to start an identifier, even with this feature enabled. - dollar_in_identifiers + >dollar_in_identifiers Accept the dollar sign (`$') as a valid character in identifiers. The at character is not allowed to start an identifier, even with this @@ -1015,7 +1020,7 @@ Here's a list of all control commands and a description, what they do: -.FILEOPT, .FOPT +.FILEOPT, .FOPT Insert an option string into the object file. There are two forms of this command, one specifies the option by a keyword, the second @@ -1045,7 +1050,7 @@ Here's a list of all control commands and a description, what they do: -.GLOBAL +.GLOBAL Declare symbols as global. Must be followed by a comma separated list of symbols to declare. Symbols from the list, that are defined somewhere @@ -1060,7 +1065,7 @@ Here's a list of all control commands and a description, what they do: -.GLOBALZP +.GLOBALZP Declare symbols as global. Must be followed by a comma separated list of symbols to declare. Symbols from the list, that are defined @@ -1076,7 +1081,7 @@ Here's a list of all control commands and a description, what they do: -.I16 +.I16 Valid only in 65816 mode. Switch the index registers to 16 bit. @@ -1086,7 +1091,7 @@ Here's a list of all control commands and a description, what they do: See also the .I8 +.I8 Valid only in 65816 mode. Switch the index registers to 8 bit. @@ -1096,7 +1101,7 @@ Here's a list of all control commands and a description, what they do: See also the .IF +.IF Conditional assembly: Evalute an expression and switch assembler output on or off depending on the expression. The expression must be a constant @@ -1106,7 +1111,7 @@ Here's a list of all control commands and a description, what they do: to TRUE. -.IFBLANK +.IFBLANK Conditional assembly: Check if there are any remaining tokens in this line, and evaluate to FALSE if this is the case, and to TRUE otherwise. @@ -1132,7 +1137,7 @@ Here's a list of all control commands and a description, what they do: See also: .IFCONST +.IFCONST Conditional assembly: Evaluate an expression and switch assembler output on or off depending on the constness of the expression. @@ -1144,7 +1149,7 @@ Here's a list of all control commands and a description, what they do: See also: .IFDEF +.IFDEF Conditional assembly: Check if a symbol is defined. Must be followed by a symbol name. The condition is true if the the given symbol is already @@ -1153,7 +1158,7 @@ Here's a list of all control commands and a description, what they do: See also: .IFNBLANK +.IFNBLANK Conditional assembly: Check if there are any remaining tokens in this line, and evaluate to TRUE if this is the case, and to FALSE otherwise. @@ -1178,7 +1183,7 @@ Here's a list of all control commands and a description, what they do: See also: .IFNDEF +.IFNDEF Conditional assembly: Check if a symbol is defined. Must be followed by a symbol name. The condition is true if the the given symbol is not @@ -1187,7 +1192,7 @@ Here's a list of all control commands and a description, what they do: See also: .IFNREF +.IFNREF Conditional assembly: Check if a symbol is referenced. Must be followed by a symbol name. The condition is true if if the the given symbol was @@ -1196,25 +1201,25 @@ Here's a list of all control commands and a description, what they do: See also: .IFP02 +.IFP02 Conditional assembly: Check if the assembler is currently in 6502 mode (see .IFP816 +.IFP816 Conditional assembly: Check if the assembler is currently in 65816 mode (see .IFPC02 +.IFPC02 Conditional assembly: Check if the assembler is currently in 65C02 mode (see .IFREF +.IFREF Conditional assembly: Check if a symbol is referenced. Must be followed by a symbol name. The condition is true if if the the given symbol was @@ -1236,7 +1241,7 @@ Here's a list of all control commands and a description, what they do: See also: .IMPORT +.IMPORT Import a symbol from another module. The command is followed by a comma separated list of symbols to import. @@ -1248,7 +1253,7 @@ Here's a list of all control commands and a description, what they do: -.IMPORTZP +.IMPORTZP Import a symbol from another module. The command is followed by a comma separated list of symbols to import. The symbols are explicitly imported @@ -1261,7 +1266,7 @@ Here's a list of all control commands and a description, what they do: -.INCBIN +.INCBIN Include a file as binary data. The command expects a string argument that is the name of a file to include literally in the current segment. @@ -1273,7 +1278,7 @@ Here's a list of all control commands and a description, what they do: -.INCLUDE +.INCLUDE Include another file. Include files may be nested up to a depth of 16. @@ -1284,7 +1289,7 @@ Here's a list of all control commands and a description, what they do: -.LEFT +.LEFT Builtin function. Extracts the left part of a given token list. @@ -1318,7 +1323,7 @@ Here's a list of all control commands and a description, what they do: See also the .LINECONT +.LINECONT Switch on or off line continuations using the backslash character before a newline. The option is off by default. @@ -1338,7 +1343,7 @@ Here's a list of all control commands and a description, what they do: -.LIST +.LIST Enable output to the listing. The command must be followed by a boolean switch ("on", "off", "+" or "-") and will enable or disable listing @@ -1356,7 +1361,7 @@ Here's a list of all control commands and a description, what they do: -.LISTBYTES +.LISTBYTES Set, how many bytes are shown in the listing for one source line. The default is 12, so the listing will show only the first 12 bytes for any @@ -1373,7 +1378,7 @@ Here's a list of all control commands and a description, what they do: -.LOCAL +.LOCAL This command may only be used inside a macro definition. It declares a list of identifiers as local to the macro expansion. @@ -1392,7 +1397,7 @@ Here's a list of all control commands and a description, what they do: You get an error when using .LOCALCHAR +.LOCALCHAR Defines the character that start "cheap" local labels. You may use one of '@' and '?' as start character. The default is '@'. @@ -1416,7 +1421,7 @@ Here's a list of all control commands and a description, what they do: -.MACPACK +.MACPACK Insert a predefined macro package. The command is followed by an identifier specifying the macro package to insert. Available macro @@ -1440,7 +1445,7 @@ Here's a list of all control commands and a description, what they do: See separate section about macros packages. -.MAC, .MACRO +.MAC, .MACRO Start a classic macro definition. The command is followed by an identifier (the macro name) and optionally by a comma separated list of identifiers @@ -1448,7 +1453,7 @@ Here's a list of all control commands and a description, what they do: See separate section about macros. -.MATCH +.MATCH Builtin function. Matches two token lists against each other. This is most useful within macros, since macros are not stored as strings, but @@ -1500,7 +1505,7 @@ Here's a list of all control commands and a description, what they do: reserved keyword "A". -.MID +.MID Builtin function. Takes a starting index, a count and a token list as arguments. Will return part of the token list. @@ -1537,7 +1542,7 @@ Here's a list of all control commands and a description, what they do: See also the .ORG +.ORG Start a section of absolute code. The command is followed by a constant expression that gives the new PC counter location for which the code is @@ -1552,7 +1557,7 @@ Here's a list of all control commands and a description, what they do: -.OUT +.OUT Output a string to the console without producing an error. This command is similiar to .P02 +.P02 Enable the 6502 instruction set, disable 65C02 and 65816 instructions. This is the default if not overridden by the .P816 +.P816 Enable the 65816 instruction set. This is a superset of the 65C02 and 6502 instruction sets. -.PAGELEN, .PAGELENGTH +.PAGELEN, .PAGELENGTH Set the page length for the listing. Must be followed by an integer constant. The value may be "unlimited", or in the range 32 to 127. The @@ -1599,7 +1604,7 @@ Here's a list of all control commands and a description, what they do: -.PARAMCOUNT +.PARAMCOUNT This builtin pseudo variable is only available in macros. It is replaced by the actual number of parameters that were given in the macro @@ -1617,13 +1622,13 @@ Here's a list of all control commands and a description, what they do: -.PC02 +.PC02 Enable the 65C02 instructions set. This instruction set includes all 6502 instructions. -.PROC +.PROC Start a nested lexical level. All new symbols from now on are in the local lexical level and are not accessible from outside. Symbols defined @@ -1656,7 +1661,7 @@ Here's a list of all control commands and a description, what they do: -.REF, .REFERENCED +.REF, .REFERENCED Builtin function. The function expects an identifier as argument in braces. The argument is evaluated, and the function yields "true" if the @@ -1669,12 +1674,39 @@ Here's a list of all control commands and a description, what they do: -.RELOC +.REPEAT + + Repeat all commands between + .macro Crypt Arg + .repeat strlen(Arg), I + .byte strat(Arg, I) .xor $55 + .endrep + .endmacro + + + +.RELOC Switch back to relocatable mode. See the .RES +.RES Reserve storage. The command is followed by one or two constant expressions. The first one is mandatory and defines, how many bytes of @@ -1691,7 +1723,7 @@ Here's a list of all control commands and a description, what they do: -.RIGHT +.RIGHT Builtin function. Extracts the right part of a given token list. @@ -1707,7 +1739,7 @@ Here's a list of all control commands and a description, what they do: See also the .RODATA +.RODATA Switch to the RODATA segment. The name of the RODATA segment is always "RODATA", so this is a shortcut for @@ -1720,7 +1752,7 @@ Here's a list of all control commands and a description, what they do: readonly data like string constants. See also the .SEGMENT +.SEGMENT Switch to another segment. Code and data is always emitted into a segment, that is, a named section of data. The default segment is @@ -1758,7 +1790,7 @@ Here's a list of all control commands and a description, what they do: -.SMART +.SMART Switch on or off smart mode. The command must be followed by a '+' or '-' character to switch the option on or off respectively. The default @@ -1781,7 +1813,25 @@ Here's a list of all control commands and a description, what they do: -.STRING +.STRAT + + Builtin function. The function accepts a string and an index as + arguments and returns the value of the character at the given position + as an integer value. The index is zero based. + + Example: + + + .macro M Arg + ; Check if the argument string starts with '#' + .if (.strat (Arg, 0) = '#') + ... + .endif + .endmacro + + + +.STRING Builtin function. The function accepts an argument in braces and converts this argument into a string constant. The argument may be an @@ -1800,7 +1850,24 @@ Here's a list of all control commands and a description, what they do: -.TCOUNT +.STRLEN + + Builtin function. The function accepts a string argument in braces and + eveluates to the length of the string. + + Example: + + The following macro encodes a string as a pascal style string with + a leading length byte. + + + .macro PString Arg + .byte .strlen(Arg), Arg + .endmacro + + + +.TCOUNT Builtin function. The function accepts a token list in braces. The function result is the number of tokens given as argument. @@ -1824,13 +1891,13 @@ Here's a list of all control commands and a description, what they do: -.WARNING +.WARNING Force an assembly warning. The assembler will output a warning message preceeded by "User warning". This warning will always be output, even if other warnings are disabled with the .WORD +.WORD Define word sized data. Must be followed by a sequence of (word ranged, but not necessarily constant) expressions. @@ -1864,7 +1931,7 @@ Here's a list of all control commands and a description, what they do: -.ZEROPAGE +.ZEROPAGE Switch to the ZEROPAGE segment and mark it as direct (zeropage) segment. The name of the ZEROPAGE segment is always "ZEROPAGE", so this is a @@ -2192,25 +2259,25 @@ with just one command. Available macro packages are: -generic +generic This macro package defines macros that are useful in almost any program. Currently, two macros are defined: .macro add Arg - clc - adc Arg + clc + adc Arg .endmacro .macro sub Arg - sec - sbc Arg + sec + sbc Arg .endmacro -longbranch +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 @@ -2248,7 +2315,7 @@ with just one command. Available macro packages are: If you have problems using the assembler, if you find any bugs, or if you're doing something interesting with the assembler, I would be glad to hear from you. Feel free to contact me by email -(). +(). @@ -2279,6 +2346,7 @@ freely, subject to the following restrictions: +