For a script I created for another question, I had to capitalise filenames passed to NASM in string defines. I used %substr to extract single characters in a %rep loop, with a repetition count from %strlen. I tried the following way to capitalise a character:
$ cat test.asm
%define cc 'a'
%if cc >= 'a' && cc <= 'z'
%strcat cc cc - 'a' + 'A'
%endif
But that failed as follows:
$ nasm test.asm
test.asm:3: error: non-string passed to `%strcat' (9)
$
The error message is generated by this bit in the NASM preprocessor source: https://repo.or.cz/nasm.git/blob/437e0ffa01505d173a8b9cfe2decf74f2e9795a5:/asm/preproc.c#l3472
Which uses the token type the definition of which is in https://repo.or.cz/nasm.git/blob/437e0ffa01505d173a8b9cfe2decf74f2e9795a5:/asm/preproc.c#l207 (9 seems to be TOK_OTHER.)
I eventually ended up with this way of solving the problem, though it seems weird enough that there might be a better one.
%if cc >= 'a' && cc <= 'z'
%substr cc "ABCDEFGHIJKLMNOPQRSTUVWXYZ" (cc - 'a' + 1)
%endif
From my source at https://hg.ulukai.org/ecm/bootimg/file/f8c890f92116f2593c1e2016a71f95dfd7bbcd36/bootimg.asm#l314