]> Shamusworld >> Repos - rmac/commitdiff
Produce error when ".opt +o" or ".opt ~o" is encountered. Also, small doc additions
authorggn <ggn.dbug@gmail.com>
Tue, 13 Oct 2020 17:06:35 +0000 (20:06 +0300)
committerShamus Hammons <jlhamm@acm.org>
Wed, 9 Jun 2021 00:49:41 +0000 (19:49 -0500)
docs/rmac.rst
rmac.c

index bfbd66c08eac4e3abf390d77995a0bfca59f15e2..24110c46eb220330d3104d49a1356e26b5d2eb12 100644 (file)
@@ -404,7 +404,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,6 +414,8 @@ 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.
@@ -422,7 +424,7 @@ necessary to make other assemblers' source code assemble.
 * 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:
 
    ::
@@ -942,6 +944,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).
@@ -1207,6 +1232,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
diff --git a/rmac.c b/rmac.c
index 0da81bec4ee37d3d4b941628f393c87f64b86a80..8ea0189e02ef740ecce71b59fad8c4b5076140f9 100644 (file)
--- a/rmac.c
+++ b/rmac.c
@@ -68,7 +68,6 @@ void strtoupper(char * s)
                *s++ &= 0xDF;
 }
 
-
 //
 // Manipulate file extension.
 //
@@ -145,7 +144,6 @@ int nthpath(char * env_var, int itemno, char * buf)
        return 1;
 }
 
-
 //
 // Display command line help
 //
@@ -185,7 +183,7 @@ void DisplayHelp(void)
                "                    o7: clr.l Dx to moveq #0,Dx                       (off)\n"
                "                    o8: adda.w/l #x,Dy to addq.w/l #x,Dy              (off)\n"
                "                    o9: adda.w/l #x,Dy to lea x(Dy),Dy                (off)\n"
-               "                    op: Enforce PC relative (alternative: o10)        (off)\n"
+               "                    o10: Enforce PC relative (alternative: op)        (off)\n"
                "  ~o[value]         Turn a specific optimisation off\n"
                "  +oall             Turn all optimisations on\n"
                "  ~oall             Turn all optimisations off\n"
@@ -223,7 +221,6 @@ void DisplayVersion(void)
                "V%01i.%01i.%01i %s (%s)\n\n", MAJOR, MINOR, PATCH, __DATE__, PLATFORM);
 }
 
-
 //
 // Parse optimisation options
 //
@@ -238,6 +235,9 @@ int ParseOptimization(char * optstring)
                else if (*optstring != '~')
                        return ERROR;
 
+        if (optstring[2] == 0)
+            return error(".opt called with zero arguments");
+
                if ((optstring[2] == 'a' || optstring[2] == 'A')
                        && (optstring[3] == 'l' || optstring[3] == 'L')
                        && (optstring[4] == 'l' || optstring[4] == 'L'))
@@ -284,7 +284,6 @@ int ParseOptimization(char * optstring)
        return OK;
 }
 
-
 //
 // Process command line arguments and do an assembly
 //
@@ -756,7 +755,6 @@ int Process(int argc, char ** argv)
        return errcnt;
 }
 
-
 //
 // Determine processor endianess
 //
@@ -771,7 +769,6 @@ int GetEndianess(void)
        return 1;
 }
 
-
 //
 // Application entry point
 //
@@ -798,4 +795,3 @@ int main(int argc, char ** argv)
 
        return 0;
 }
-