I checked the source code and it appears that the problem is in the
stm8/gen.c in function genCall. I changed the following line:
emit2 ("call", "%s", aopGet2 (left->aop, 0));
to
emit2 ("call", "%s", left->aop->aopu.immd);
and it looks like to solve the problem. I hope someone correct me or the
source code.On Tue, Apr 14, 2020 at 4:37 PM Vahid Bashiri <[email protected]> wrote: > This is not the assembler. > For first call generated code is: call #(_func + 0) which is not a valid > stm8 assembly. For second call sdcc generates call (x) where x contains > the address of _func which is correct. > > On Tue, Apr 14, 2020 at 1:30 PM Philipp Klaus Krause <[email protected]> wrote: > >> Am 14.04.20 um 07:51 schrieb Vahid Bashiri: >> > int func(void *var,int val); >> > typedef int (*SetVal)(void *, int); >> > typedef struct { >> > int val; >> > SetVal setval; >> > } my_struct; >> > int main() >> > { >> > >> > my_struct str1 = {0,func}; >> > my_struct str2 = {0,func}; >> > str1.setval(&str1,11); >> > str2.setval(&str2,5); >> > return 0; >> > } >> > int func(void *var,int val) >> > { >> > my_struct *tmp = (my_struct*)var; >> > tmp->val = val; >> > return 0; >> > } >> > >> >> I can reproduce this issue; it is definitely a bug. >> >> Plese report it in the bug tracker: >> https://sourceforge.net/p/sdcc/bugs/ >> >> Though looking at the asm, at first sight it looks more like an >> assembler bug rather than a compiler bug to me. >> >> Philipp >> >> _______________________________________________ >> Sdcc-user mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/sdcc-user >> >
_______________________________________________ Sdcc-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sdcc-user
