Since people like form 1, I'd now think we should keep it, but drop
#pragma sdcc_hash. That looks like a better way forward and also
solves the issues.

When this pragma is dropped does that mean it is no longer possible to use the # for an immediate operand?

You can still use a plain # (it already works now without using the pragma):

void h(void)
{
__asm
        add     a, #3
__endasm;
}

Or will it be limited to use outside of a macro? I wouldn't even know how to escape the #.

The C standard requires "Each # preprocessing token in the replacement list for a function-like macro shall be followed by a parameter as the next preprocessing token in the replacement list." (see section 6.10.3.2 of the current C2X standard N2912). Which makes sense, since in the standard, # is meant for stringizing macro arguments. The #pragma sdcc_hash is used to overide that.

lib/ds400/ds400.rom.c currently has the following lines:

// This macro is invalid for the standard C preprocessor, since it
// includes a hash character in the expansion, hence the SDCC specific
// pragma.
#pragma sdcc_hash +
#define ROMCALL(x) \
        mov     R6_B3, #(x & 0xff)              \
        mov     R7_B3, #((x >> 8) & 0xff)       \
        lcall   __romcall

And then uses this macro from within __asm / __endasm. This will have to be changed to e.g.:

#define HASH #
#define ROMCALL(x) \
        mov     R6_B3, HASH(x & 0xff)              \
        mov     R7_B3, HASH((x >> 8) & 0xff)       \
        lcall   __romcall

Philipp


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to