asmlnk.txt documents "up-arrow (^) construction" for strings as one of the supported options:
1.4.14 .ascii, .str, and .fcc Directives
[...]
.str /string/ or
.str ^/string/
This is in particular needed for macro string arguments, when the string contains the argument delimiter character:
Arguments which themselves contain separating characters must be
enclosed within the delimiter construct ^/ / where the
character '/' may be any character not in the argument string.
This seems to be broken though, I'm getting parsing errors from sdas if I try to use it, this simple example fails for me:
cat > testcase.s <<EOF
; works
.str /foo/
; caret-quoting should work, but fails
.str ^/foo/
EOF
$ sdas8051 testcase.s
testcase.s:4: Error: <q> missing or improper operators, terminators, or delimiters
As does the macro attempt:
cat > testcase.s <<EOF
.macro foo arg
.ascii arg
.endm
; works
foo /foo/
; caret-quoting should work, but fails
foo ^/foo/
EOF
$ sdas8051 testcase.s
testcase.s:8: Error: <q> missing or improper operators, terminators, or delimiters
I've tried both the trunk version and the Debian sdcc 4.0.0+dfsg-2 version, both fail to parse this.
Debugging with
shows the error is thrown in aslex.c:422:
which is just
in "int getmap(int d)"...
Ok, this is where it gets more interesting:
Looks like d is the delimiter (indeed 94 matches '^').
I don't see any special handling for '^' here, maybe it got removed at some point? (Or never worked?)
Even in the macro testcase, the error seems to be in the .str / .ascii parsing, so I'm guessing it passed fine through the macro.
Ohh, I think I get it. The first getnb() should be getdlm() instead (since it tries to get the delimiter character), which has the handling for '^'.
If I do that change though there is some weirdness:
works:
also works with the change:
doesn't work:
also doesn't work:
it seems like in the macro invocation, for the '^' special case, the delimiters are not passed
on into the macro, while without '^' they are...
But basically the change I made is: