]> Shamusworld >> Repos - rmac/blobdiff - docs/rmac.rst
Version bump for last commit. :-)
[rmac] / docs / rmac.rst
index bfbd66c08eac4e3abf390d77995a0bfca59f15e2..0c7c5ff9f064455251b4ed315c2c28c34146ecd2 100644 (file)
@@ -4,25 +4,23 @@ RMAC
 =====================
 Reference Manual
 ================
-version 2.0.21
+version 2.0.23
 ==============
 
 © and notes
 ===========
 
 *NOTE: Every effort has been made to ensure the accuracy and robustness of this
-manual and the associated software. However, because Reboot is constantly improving
-and updating its computer software, it is unable to guarantee
+manual and the associated software. However, the authors are constantly improving
+and updating its computer software, we is unable to guarantee
 the accuracy of printed or duplicated material after the date of publication and
 disclaims liability for changes, errors or omissions.*
 
 
-*Copyright © 2011-2020, Reboot*
+*Copyright © 2011-2022, the rmac authors*
 
 *All rights reserved.*
 
-*Reboot Document number F00000K-001 Rev. A.*
-
 Contents
 ========
 
@@ -38,7 +36,7 @@ runs on the any POSIX compatible platform and the Atari ST. It was initially wri
 at Atari Corporation by programmers who needed a high performance assembler
 for their work. Then, more than 20 years later, because there was still a need for
 such an assembler and what was available wasn't up to expectations, Subqmod
-and eventually Reboot continued work on the freely released source, adding Jaguar
+and eventually the rmac authors continued work on the freely released source, adding Jaguar
 extensions and fixing bugs. Over time the assembler has been extended by adding
 support for Motorola's 68020/30/40/60, 68881/2, DSP56001 CPUs as well as Atari's
 Object Processor (OP) found on the Atari Jaguar.
@@ -122,12 +120,14 @@ Switch               Description
 -e\ *[file[.err]]*   Direct error messages to the specified file.
 -fa                  ALCYON output object file format (implied when **-ps** is enabled).
 -fb                  BSD COFF output object file format.
+-fb                  Commodore 64 PRG format.
 -fe                  ELF output object file format.
 -fr                  Absolute address. Source code is required to have one .org statement.
 -fx                  Atari 800 com/exe/xex output object file format.
+-g                   Generate source level debug info. Requires BSD COFF object file format.
 -i\ *path*           Set include-file directory search path.
 -l\ *[file[prn]]*    Construct and direct assembly listing to the specified file.
--l\ *\*[filename]*   Create an output listing file without pagination
+-l\ *\*[filename]*   Create an output listing file without pagination.
 -m\ *cpu*            Switch CPU type
 
                       `68000 - MC68000`
@@ -153,16 +153,16 @@ Switch               Description
                       `jerry - Jaguar DSP JRISC`
 
                       -o\ *file[.o]*       Direct object code output to the specified file.
-+/~oall              Turn all optimisations on/off
-+o\ *0-10*/*p*       Enable specific optimisation
-~o\ *0-10*/*p*       Disable specific optimisation
++/~oall               Turn all optimisations on/off
++o\ *0-30*/*p*        Enable specific optimisation
+~o\ *0-30*/*p*        Disable specific optimisation
+
+                      `0: Absolute long adddresses to word`
 
-                      `0: Absolute long adddresses to word (on by default)`
-                      
-                      `1: move.l #x,Dn/An to moveq (on by default)`
+                      `1: move.l #x,Dn/An to moveq`
+
+                      `2: Word branches to short`
 
-                      `2: Word branches to short (on by default)`
-                      
                       `3: Outer displacement 0(An) to (An)`
 
                       `4: lea to addq`
@@ -177,7 +177,12 @@ Switch               Description
 
                       `9: Convert adda.w/l #x,Dy to lea x(Dy),Dy`
 
-                      `p: Force PC-Relative mode (alternative: o10)`
+                      `10: 56001 Use short format for immediate values if possible`
+
+                      `11: 56001 Auto convert short addressing mode to long (default: on)`
+
+                      `30: Enforce PC relative (alternative name: op)`
+
 -p                   Produce an executable (**.prg**) output file.
 -ps                  Produce an executable (**.prg**) output file with symbols.
 -px                  Produce an executable (**.prg**) output file with extended symbols.
@@ -185,21 +190,22 @@ Switch               Description
 -r *size*            automatically pad the size of each
                      segment in the output file until the size is an integral multiple of the
                      specified boundary. Size is a letter that specifies the desired boundary.
-                     
+
                       `-rw Word (2 bytes, default alignment)`
 
                       `-rl Long (4 bytes)`
 
                       `-rp Phrase (8 bytes)`
-                      
+
                       `-rd Double Phrase (16 bytes)`
-                      
+
                       `-rq Quad Phrase (32 bytes)`
 -s                   Warn about unoptimized long branches and applied optimisations.
 -u                   Force referenced and undefined symbols global.
 -v                   Verbose mode (print running dialogue).
--x                   Turn on debugging mode
+-x                   Turn on debugging mode.
 -yn                  Set listing page size to n lines.
+-4                   Use C style operator precedence.
 file\ *[s]*          Assemble the specified file.
 ===================  ===========
 
@@ -229,6 +235,19 @@ the table.
  file is created. Beware! If an assembly produces no errors, any error file from
  a previous assembly is not removed.
 
+**-g**
+ The **-g** switch causes RMAC to generate source-level debug symbols using the
+ stabs format. When linked with a compatible linker such as RLN, these symbols
+ can be used by source-level debuggers such as rdbjag, wdb, or gdb to step
+ through assembly code line-by-line with all the additional context of labels,
+ macros, constants, register equates, etc. available in the original assembly
+ listings rather than relying on the simple disassembly or raw machine code
+ available when stepping through instruction-by-instruction. This option only
+ works with the BSD COFF object file format, as the others do not use the
+ a.out-style symbol tables required by stabs, and RMAC does not currently
+ support placing stabs debug symbols in their own dedicated section in ELF
+ format object files.
+
 **-i**
  The **-i** switch allows automatic directory searching for include files. A list of
  semi-colon seperated directory search paths may be mentioned immediately
@@ -291,6 +310,9 @@ the table.
   space), sets the number of lines in a page. RMAC will produce *N* lines
   before emitting a form-feed. If *N* is missing or less than 10 an error message is
   generated.
+**-4**
+  Use C style order of precedence in expressions. See `Order of Evaluation`_ for more
+  information.
 
 `Using RMAC`_
 ===============
@@ -404,7 +426,7 @@ necessary to make other assemblers' source code assemble.
   **ifne**, **ifeq** (etc.), and **endc**.
 * The tilde (~) character is an operator, and back-quote (`) is an illegal character.
   AS68 permitted the tilde and back-quote characters in symbols.
-* There are no equivalents to org or section directives.
+* There are no equivalents to org or section directives apart from .text, .data, .bss.
   The **.xdef** and **.xref** directives are not implemented,
   but **.globl** makes these unnecessary anyway.
 
@@ -414,15 +436,18 @@ necessary to make other assemblers' source code assemble.
 
                                 * = expression
 
+  Exceptions to this rule are when outputting a binary using the **-fr** switch,
+  6502 mode, and Jaguar GPU/DSP.
 * Back-slashes in strings are "electric" characters that are used to escape C-like
   character codes. Watch out for GEMDOS path names in ASCII constants -
   you will have to convert them to double-backslashes.
 * Expression evaluation is done left-to-right without operator precedence. Use parentheses to
-  force the expression evaluation as you wish.
+  force the expression evaluation as you wish. Alternatively, use the **-4** switch to switch
+  to C style precedence. For more information refer to `Order of Evaluation`_.
 * Mark your segments across files.
   Branching to a code segment that could be identified as BSS will cause a "Error: cannot initialize non-storage (BSS) section"
 * In 68020+ mode **Zan** and **Zri** (register suppression) is not supported.
-* rs.b/rs.w/rs.l/rscount/rsreset can be simulated in rmac using abs.
+* rs.b/rs.w/rs.l/rscount/rsreset can be simulated in rmac using **.abs**.
   For example the following source:
 
    ::
@@ -432,7 +457,7 @@ necessary to make other assemblers' source code assemble.
     label2: rs.w 10
     label3: rs.l 5
     label4: rs.b 2
-   
+
     size_so_far equ rscount
 
   can be converted to:
@@ -444,7 +469,7 @@ necessary to make other assemblers' source code assemble.
     label2: ds.w 10
     label3: ds.l 5
     label4: ds.b 2
-   
+
     size_so_far equ ^^abscount
 * A rare case: if your macro contains something like:
 
@@ -508,7 +533,7 @@ As an addition, the exclamation mark character (**!**) can be placed at the very
 character of a line to disbale all optimisations for that specific line, i.e.
 
   ::
-      
+
       !label: operator operand(s)  ; comment
 
 `Equates`_
@@ -626,7 +651,7 @@ and may not be used as symbols (e.g. labels, equates, or the names of macros):
       a0 a1 a2 a3 a4 a5 a6 a7
       Tom/Jerry:
       r0 r1 r2 r3 r4 r5 r6 r7
-      r8 r9 r10 r11 r12 rl3 r14 ri5
+      r8 r9 r10 r11 r12 r13 r14 r15
       6502:
       x y a
       DSP56001:
@@ -636,7 +661,7 @@ and may not be used as symbols (e.g. labels, equates, or the names of macros):
       n0 n1 n2 n3 n4 n5 n6 n7
       m0 m1 m2 m3 m4 m5 m6 m7
       r0 r1 r2 r3 r4 r5 r6 r7
-      
+
 
 `Constants`_
 ''''''''''''
@@ -739,6 +764,24 @@ true.
 Thus the expression "1+2*3" evaluates to 9, not 7. However, precedence may be
 forced with parenthesis (**()**) or square-brackets (**[]**).
 
+All the above behavior is the default. However if the command line switch **-4**
+is used, then C style of operator precedence is enforced. The following list
+shows the order of precedence in this mode, from lowest to highest:
+
+ * bitwise XOR ^
+
+ * bitwise OR |
+
+ * bitwise AND &
+
+ * relational = < <= >= > !=
+
+ * shifts << >>
+
+ * sum + -
+
+ * product * /
+
 `Types`_
 '''''''''
 Expressions belong to one of three classes: undefined, absolute or relocatable. An
@@ -803,7 +846,7 @@ Operator                            Description
 **~**                               Tilde: bitwise not (l's complement).
 **^^defined** *symbol*              True if symbol has a value.
 **^^referenced** *symbol*           True if symbol has been referenced.
-**^^streq** *stringl*, *string2*    True if the strings are equal.
+**^^streq** *string1*, *string2*    True if the strings are equal.
 **^^macdef** *macroName*            True if the macro is defined.
 **^^abscount**                      Returns the size of current .abs section
 **^^filesize** *string_filename*    Returns the file size of supplied filename
@@ -835,7 +878,9 @@ Operator     Description
 ===========  ==============================================
 
  * All binary operators have the same precedence:
-   expressions are evaluated strictly left to right.
+   expressions are evaluated strictly left to right,
+   with the exception of the **-4** switch. For more information
+   refer to `Order of Evaluation`_.
 
  * Division or modulo by zero yields an assembly error.
 
@@ -923,9 +968,11 @@ symbol **debug** external, instead of including another source file).
 Assembler directives may be any mix of upper- or lowercase. The leading periods
 are optional, though they are shown here and their use is encouraged. Directives
 may be preceeded by a label; the label is defined before the directive is executed.
-Some directives accept size suffixes (**.b**, **.s**, **.w** or **.1**); the default is word (**.w**) if no
-size is specified. The **.s** suffix is identical to **.b**. Directives relating to the 6502 are
-described in the chapter on `6502 Support`_.
+Some directives accept size suffixes (**.b**, **.s**, **.w**, **.1**, **.d**, **.x**, **.p**, or  **.q**);
+the default is word (**.w**) if no size is specified. The **.s** suffix is identical to **.b**,
+with the exception of being used in a **dc** statement. In that case the **.s**
+refers to single precision floating point numbers.
+Directives relating to the 6502 are described in the chapter on `6502 Support`_.
 
 
 
@@ -942,6 +989,29 @@ described in the chapter on `6502 Support`_.
    Therefore, to align GPU/DSP code, align the current section before and
    after the GPU/DSP code.
 
+**.print**
+   This directive is similar to the standard ‘C’ library printf() function
+   and is used to print user messages from the assembly process. You can
+   print any string or valid expression. Several format flags that can be used
+   to format your output are also supported.
+
+          ::
+
+           /x hexadecimal
+           /d signed decimal
+           /u unsigned decimal
+           /w word
+           /l long
+
+   For example:
+
+          ::
+
+           MASK .equ $FFF8
+           VALUE .equ -100000
+            .print “Mask: $”,/x/w MASK
+            .print “Value: “,/d/l VALUE
+
 **.phrase**
 
    Align the program counter to the next integral phrase boundary (8 bytes).
@@ -966,7 +1036,14 @@ described in the chapter on `6502 Support`_.
    Therefore, to align GPU/DSP code, align the current section before and
    after the GPU/DSP code.
 
-   **.assert** *expression* [,\ *expression*...]
+**.align** *expression*
+
+  A generalised version of the above directives, this will align the program
+  counter to the boundary of the specified value. Note that there is not much
+  error checking happening (only values 0 and 1 are rejected). Also note that
+  in DSP56001 mode the align value is assumed to be in DSP words, i.e. 24 bits.
+
+**.assert** *expression* [,\ *expression*...]
 
    Assert that the conditions are true (non-zero). If any of the comma-seperated
    expressions evaluates to zero an assembler warning is issued. For example:
@@ -1019,14 +1096,17 @@ described in the chapter on `6502 Support`_.
 **.opt** *"~On"*
 **.opt** *"+Oall"*
 **.opt** *"~Oall"*
-   
+
    These directives control the optimisations that rmac applies to the source
    automatically. Each directive is applied immediately from the line encountered
    onwards. So it is possible to turn specific optimisations on and off globally
    (when placed at the start of the first file) or locally (by turning desired
    optimisations on and off at certain parts of the source). For a list of the
    optimisations (*n*) available please consult the table in section `The Command Line`_.
-   **all**, as expected, turns all available optimisations on or off.
+
+   **all**, as expected, turns all available optimisations on or off. An exception to this
+   is *o10*/*op* as this is not an optimisation that should be turned on unless the user
+   absolutely needs it.
 
    Lastly, as a "creature comfort" feature, if the first column of any line is prefixed
    with an exclamation mark (*!*) then for that line all optimisations are turned off.
@@ -1036,7 +1116,6 @@ described in the chapter on `6502 Support`_.
    Start an absolute section, beginning with the specified location (or zero, if
    no location is specified). An absolute section is much like BSS, except that
    locations declared with .ds are based absolute. This directive is useful for
-
    declaring structures or hardware locations.
    For example, the following equates:
 
@@ -1097,15 +1176,15 @@ described in the chapter on `6502 Support`_.
            spf_emx_colouropt:  ds.l    1
            spf_emx_psmask:     ds.l    16
            spf_emx_psmaskopt:  ds.l    16
-           
+
            .68000
            ;*-------------------------------------------------------*
-           
+
                move #spf_em_colour,d0
                move #spf_emx_colour,d0
 
    In this example, *spf_em_colour* and *spf_emx_colour* will have the same value.
-           
+
 **.comm** *symbol*, *expression*
 
    Specifies a label and the size of a common region. The label is made global,
@@ -1119,7 +1198,7 @@ described in the chapter on `6502 Support`_.
    and JR instructions for GPU and DSP code. For example:
 
     ::
-   
+
      Always .ccdef 0
      . . .
           jump Always,(r3) ; 'Always' is actually 0
@@ -1128,7 +1207,7 @@ described in the chapter on `6502 Support`_.
 
    Undefines a register name (regname) previously assigned using the
    .CCDEF directive. This is only implemented in GPU and DSP code
-   sections.     
+   sections.
 
 **.dc.i** *expression*
 
@@ -1207,6 +1286,17 @@ described in the chapter on `6502 Support`_.
                bne   .1               ; (no -- try again)
                rts                    ; return string length
 
+**.error** ["*string*"]
+
+  Aborts the build, optionally printing a user defined string. Can be useful
+  inside conditional assembly blocks in order to catch errors. For example:
+
+        ::
+
+         .if ^^defined JAGUAR
+           .error "TOS cannot be built on Jaguar, don't be silly"
+         .endif
+
 **.end**
 
    End the assembly. In an include file, end the include file and resume assembling
@@ -1216,11 +1306,11 @@ described in the chapter on `6502 Support`_.
 
 **.equr** *expression*
 
-   Allows you to name a register. This is only implemented for GPU/DSP
-   code sections. For example:
+   Allows you to name a register. For example:
 
     ::
 
+     .gpu
      Clipw .equr r19
      . . .
           add ClipW,r0 ; ClipW actually is r19
@@ -1304,12 +1394,12 @@ described in the chapter on `6502 Support`_.
 **.incbin** "*file*" [, [*size*], [*offset*]]
 
    Include a file as a binary. This can be thought of a series of **dc.b** statements
-   that match the binary bytes of the included file, inserted at the location of the 
+   that match the binary bytes of the included file, inserted at the location of the
    directive. The directive is not allowed in a BSS section. Optional parameters
    control the amount of bytes to be included and offset from the start of the file.
    All the following lines are valid:
 
-              ::   
+              ::
                 .incbin "test.bin"          ; Include the whole file
                 .incbin "test.bin",,$30     ; Skip the first 48 bytes
                 .incbin "test.bin",$70,$30  ; Include $70 bytes starting at offset $30
@@ -1382,11 +1472,11 @@ described in the chapter on `6502 Support`_.
 ============ ======  =======
 Definition   Bit(s)  Meaning
 ============ ======  =======
-PF_FASTLOAD  0       If set, clear only the BSS area on program load, otherwise clear the entire heap. 
-PF_TTRAMLOAD 1       If set, the program may be loaded into alternative RAM, otherwise it must be loaded into standard RAM. 
-PF_TTRAMMEM  2       If set, the program's Malloc() requests may be satisfied from alternative RAM, otherwise they must be satisfied from standard RAM. 
+PF_FASTLOAD  0       If set, clear only the BSS area on program load, otherwise clear the entire heap.
+PF_TTRAMLOAD 1       If set, the program may be loaded into alternative RAM, otherwise it must be loaded into standard RAM.
+PF_TTRAMMEM  2       If set, the program's Malloc() requests may be satisfied from alternative RAM, otherwise they must be satisfied from standard RAM.
 --           3       Currently unused.
-See left.    4 & 5   If these bits are set to 0 (PF_PRIVATE), the processes' entire memory space will be considered private (when memory protection is enabled).If these bits are set to 1 (PF_GLOBAL), the processes' entire memory space will be readable and writable by any process (i.e. global).If these bits are set to 2 (PF_SUPERVISOR), the processes' entire memory space will only be readable and writable by itself and any other process in supervisor mode.If these bits are set to 3 (PF_READABLE), the processes' entire memory space will be readable by any application but only writable by itself. 
+See left.    4 & 5   If these bits are set to 0 (PF_PRIVATE), the processes' entire memory space will be considered private (when memory protection is enabled).If these bits are set to 1 (PF_GLOBAL), the processes' entire memory space will be readable and writable by any process (i.e. global).If these bits are set to 2 (PF_SUPERVISOR), the processes' entire memory space will only be readable and writable by itself and any other process in supervisor mode.If these bits are set to 3 (PF_READABLE), the processes' entire memory space will be readable by any application but only writable by itself.
 --           6-15    Currently unused.
 ============ ======  =======
 
@@ -1526,21 +1616,19 @@ The assembler provides "creature comforts" when it processes 68000 mnemonics:
    their quick forms; **ADDQ** and **SUBQ** must be explicit.
 
  * All optimisations are controllable using the **.opt** directive. Refer to its
-   description in section `Directives`_. 
+   description in section `Directives`_.
 
  * All optimisations are turned off for any source line that has an exclamation mark
    (*!*) on their first column.
 
- * Optimisation switches 0, 1 and 2 are turned on by default for legacy reasons.
+ * Optimisation switch 11 is turned on by default for compatibility with the
+   Motorola reference 56001 DSP assembler.
    All other levels are off by default. (refer to section `The Command Line`_
    for a description of all the switches).
 
  * Optimisation warnings are off by default. Invoke RMAC with the *-s* switch to
    turn on warnings in console and listing output.
 
- * In DSP56001 mode size optimisations are on by default. Currently there is no
-   way to disable this behaviour.
-
  * In GPU/DSP code sections, you can use JUMP (Rx) in place of JUMP T, (Rx) and JR
    (Rx) in place of JR T,(Rx).
 
@@ -1792,7 +1880,7 @@ modes.
 `Condition Codes`_
 ''''''''''''''''''
 The following condition codes for the GPU/DSP JUMP and JR instructions are built-in:
+
   ::
 
    CC (Carry Clear) = %00100
@@ -1966,7 +2054,7 @@ Atari Falcon XBIOS) and *.p56* (binary equivalent of *.lod*)
   distinguish between the two. rmac needs the user to be explicit and will
   generate an error if the programmer tries to use syntax from one instruction
   to the other.
-- Similarly Motorola's assembler can alias **move** with **movec**, **movep** 
+- Similarly Motorola's assembler can alias **move** with **movec**, **movep**
   and **movem**. rmac also not accept such aliasing and generate an error.
 - Motorola's assembler uses the underscore character (*_*) to define local
   labels. In order for rmac to maintain a uniform syntax across all platforms,
@@ -1982,13 +2070,16 @@ Atari Falcon XBIOS) and *.p56* (binary equivalent of *.lod*)
 
 `6502 Support`_
 ===============
-RMAC will generate code for the Motorola 6502 microprocessor. This chapter
+RMAC will generate code for the MOS 6502 microprocessor. This chapter
 describes extra addressing modes and directives used to support the 6502.
 
 As the 6502 object code is not linkable (currently there is no linker) external
 references may not be made. (Nevertheless, RMAC may reasonably be used for
 large assemblies because of its blinding speed.)
 
+Currently there is no support for undocumented opcodes. This will be addressed
+in a future release.
+
 `6502 Addressing Modes`_
 ''''''''''''''''''''''''
 All standard 6502 addressing modes are supported, with the exception of the
@@ -2065,6 +2156,8 @@ the *.exe* format consists of chunks of this format (one after the other):
      04-05      End Address. The last byte to load for this segment
      06-..      The actual segment data to load (End Address-Start Address + 1 bytes)
 
+In addition there is the standard output format for Commodore 64 binaries (.PRG).
+
 `Error Messages`_
 =================
 
@@ -2140,10 +2233,6 @@ order, along with a short description of what may have caused the problem.
 
     You tried to ``.comm`` a symbol that was already defined.
 
-**.ds permitted only in BSS**
-
-    You tried to use ``.ds`` in the text or data section.
-
 **.init not permitted in BSS or ABS**
 
     You tried to use ``.init`` in the BSS or ABS section.
@@ -2390,11 +2479,6 @@ order, along with a short description of what may have caused the problem.
   The expression has an undefined value because of a forward reference, or an
   undefined or external symbol.
 
-**unimplemented addressing mode**
-
-  You tried to use 68020 "square-bracket" notation for a 68020 addressing mode.
-  RMAC does not support 68020 addressing modes.
-
 **unimplemented directive**
 
   You have found a directive that didn't appear in the documentation. It doesn't
@@ -2409,11 +2493,6 @@ order, along with a short description of what may have caused the problem.
   You followed a ^^ with something other than one of the names defined, referenced
   or streq.
 
-**unsupported 68020 addressing mode**
-
-  The assembler saw a 68020-type addressing mode. RMAC does not assemble
-  code for the 68020 or 68010.
-
 **unterminated string**
 
   You specified a string starting with a single or double quote, but forgot to type