From 382f97b0b9f6bbe6ec041810644d325af8c3d6db Mon Sep 17 00:00:00 2001 From: ggn Date: Wed, 6 Mar 2024 16:12:24 +0200 Subject: [PATCH] Fix for issue #227 - add hex value parsing to -Dsymbol=value --- docs/rmac.rst | 10 +++++----- rmac.c | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/rmac.rst b/docs/rmac.rst index 0c7c5ff..9cacee9 100644 --- a/docs/rmac.rst +++ b/docs/rmac.rst @@ -116,7 +116,7 @@ is noname.o. The **-o** switch (see below) can be used change the output file na =================== =========== Switch Description =================== =========== --dname\ *[=value]* Define symbol, with optional value. +-dname\ *[=value]* Define symbol, with optional value. Prefix value with **$** for hexadecimal input. -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. @@ -152,7 +152,7 @@ Switch Description `jerry - Jaguar DSP JRISC` - -o\ *file[.o]* Direct object code output to the specified file. +-o\ *file[.o]* Direct object code output to the specified file. +/~oall Turn all optimisations on/off +o\ *0-30*/*p* Enable specific optimisation ~o\ *0-30*/*p* Disable specific optimisation @@ -715,8 +715,8 @@ bits set (i.e. character codes 128...255). You should be aware that backslash characters are popular in GEMDOS path names, and that you may have to escape backslash characters in your existing source -code. For example, to get the file "'c:\\auto\\ahdi.s'" you would specify the string -"`c:\\\\auto\\\\ahdi.s`". +code. For example, to get the file ``c:\auto\ahdi.s`` you would specify the string +``c:\\auto\\ahdi.s``. `Register Lists`_ ''''''''''''''''' @@ -1699,7 +1699,7 @@ by number. ============ ================================================ Special Form Description ============ ================================================ -``\\`` a single "\", +``\\`` a single "\\", ``\~`` a unique label of the form "Mn" ``\#`` the number of arguments actually specified ``\!`` the "dot-size" specified on the macro invocation diff --git a/rmac.c b/rmac.c index 17715f7..acfa69e 100644 --- a/rmac.c +++ b/rmac.c @@ -427,7 +427,24 @@ int Process(int argc, char ** argv) } sy->sattr = DEFINED | EQUATED | ABS; - sy->svalue = (*s ? (uint64_t)atoi(s) : 0); + sy->svalue = 0; + if (*s) + { + if (*s == '$') + { + // Hex number + s++; + if (*s) + { + sy->svalue = strtol(s, 0, 16); + } + } + else + { + sy->svalue = (uint64_t)atoi(s); + } + } + //sy->svalue = (*s ? (uint64_t)atoi(s) : 0); break; case 'e': // Redirect error message output case 'E': -- 2.40.1.windows.1