Hi Philipp,

Philipp Klaus Krause schreef op 2022-07-14 12:58:
SDCC currently supports two forms of inline assembler:

1:
__asm
asm code here
__endasm;

and

2:
__asm("asm code here");

Does (or will) this second form also support multiple asm instructions? AFAIK it doesn't. And does it not mess up the asm output and debug line numbers when it is used in a macro?
ISTR that I solved this in the past for form 1.

E.g.
#define NOPS __asm \
                 nop ; my comment \
                 nop \
             __endasm

Which should appear in the generated asm file as two lines when invoked.

void myfunc(void) __naked
{
    NOPS;         // I expect two lines in the asm here
int a = 1 /0; // division by zero should point to this line, not the next.
}

Form 1 requires some ugly hacks to avoid conflicts in the preprocessor.
I wonder if we could drop those, and maybe even change the keyword in
form 2 to __asm__.

Does anyone rely on form 1 and would not want support for it dropped?
Any opinions on the possible rename of form 2?

I have no objections against renaming with a deprecation period, though I do wonder why.

For comparison, GCC and clang both use:

__asm__("asm code here");

Philipp

Maarten


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

Reply via email to