From 5c830e8dbf40798d8936a06ba660a167b6410cd9 Mon Sep 17 00:00:00 2001 From: ggn Date: Tue, 13 Oct 2020 20:06:35 +0300 Subject: [PATCH] Produce error when ".opt +o" or ".opt ~o" is encountered. Also, small doc additions --- docs/rmac.rst | 40 ++++++++++++++++++++++++++++++++++++++-- rmac.c | 12 ++++-------- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/docs/rmac.rst b/docs/rmac.rst index bfbd66c..24110c4 100644 --- a/docs/rmac.rst +++ b/docs/rmac.rst @@ -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 0da81be..8ea0189 100644 --- 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; } - -- 2.37.2