News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Arnaud

SDCC 3.6.8 (CPCTelera 1.4.2) assembly compilation problem.

Started by Arnaud, 20:54, 17 July 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Arnaud

Hello,
i tried to compile my project (CPCTelera 1.4) with the latest CPCTelera and i have a compilation error i don't know how handle.

src/utils\ZX7Decrunch.h:17: error 9: FATAL Compiler Internal Error in file '/home/ArnaudPC/cpctelera-1.4.2/cpctelera/tools/sdcc-3.6.8-r9946/src/src/z80/gen.c' line number '4587' : Unimplemented __z88dk_callee support on callee side
Contact Author with source code


I guess the problem is in the C binding.

void ZX7Decrunch(const u8* source, u8* target) __z88dk_callee   
{
    source;
    target;
        __asm
            pop af
            pop hl
            pop de
            push af
            push ix

            call _ZX7_decrunch

            pop ix
        __endasm;
}




       
  • I tried to use the keyword __naked, it compiles but doesn't work (cpc not responding)
  • I also tried to put all the asm from C in the .s file, it compiles and i have the same problem.
In my searches, i tried with CPCTelera 1.4 to use the keyword __naked and it doesn't work, it seems to break my C binding.

Thanks,
Arnaud.

ronaldo

The problem seems quite clear: The use of the calling convention __z88dk_callee is not implemented for the callee side, that is, for a C function that has to be managed by the compiler. As your function is not __naked, it means that you are asking the compiler to generate code for managing parameter passing and returning. And the compiler is telling you that this kind of code generation is not implemented yet for __z88dk_callee functions.

The solution is to declare the function as __naked and add a ret statement at the end,

void ZX7Decrunch(const u8* source, u8* target) __z88dk_callee __naked
{
    source;
    target;
        __asm
            pop af
            pop hl
            pop de
            push af
            push ix

            call _ZX7_decrunch

            pop ix

            ret
        __endasm;
}


However, personally I would rather recommend not to define assembly funtions as C functions. It is preferably, and much more clear and flexible to define them directly as assembly functions in their own file. You can do it this way (assume this code is for a file named src/asmdecrunch.s):


;;
;; You may need to declare the symbol _ZX7_decrunch as global to tell the compiler that it exists
;;
.globl _ZX7_decrunch
_ZX7Decrunch::

            pop af
            pop hl
            pop de
            push af
            push ix

            call _ZX7_decrunch

            pop ix

            ret


Then, in your C code you only need the declaration of the function to tell the compiler how to use it:


void ZX7Decrunch(const u8* source, u8* target) __z88dk_callee;


You may want to place this declaration in a header file and include it wherever you want to call your funcion.

Arnaud

I make the modification with __naked and it works (for both CPCTelera 1.4 et 1.4.2) but only for my test project of ZXDecrunch  :doh:

It seems something else was broken with new SDCC compiler in my other project.

Thanks for help.

Powered by SMFPacks Menu Editor Mod