compatibility8051sdcc

`_naked`: Trying to compile legacy 8051 (FX2) code with SDCC, newer version stumbles


I have legacy code for an embedded 8051 core (in a cypress FX2) that used to compile with other versions of SDCC. However, current SDCC doesn't know the _naked qualifier:

delay.c:27: syntax error: token -> '_naked' ; column 21

as triggered by

static void
udelay1 (void) _naked
{
  _asm              ; lcall that got us here took 4 bus cycles
    ret         ; 4 bus cycles
  _endasm;
}

and other occurrences.

As _naked practically is supposed to tell the C compiler to "nah, ignore the fact that you're a C compiler and understand that you'd need to save frame context", I don't feel like I should just #define it away.

Is there any solution to this? Should I just go ahead and manually inline the assembler wherever a _naked function is used? I feel like I'd betraying the compiler on a CALL there, and that would change the timing.


Solution

  • _naked was replaced by __naked in newer versions of SDCC. Same applies to asm/__asm, at/__at, interrupt,bit,xdata/__….

    So, this turned out to be an exercise in regex replacements.

    I'm still having linker/ranlib/mostly ar problems, and CMake ignores what I instruct it to use as compilers, but oh well.