Page 1 of 1

sdcc compile mangles defm

Posted: Fri Mar 04, 2016 11:34 pm
by dom
Bit of a corner case that came up when I was playing with one of the z88 apps:

Code: Select all

#include <stdio.h>

int main()
{
        puts("Contact: xyz@da");
#asm
        defm    "Contact: xyz@dd"
#endasm
}
results in:

Code: Select all

        defm    "Contact:
        xyz@dd"
        ret
___str_0:
        DEFM "Contact: xyz@da"
        DEFB 0x00
The trigger seems to be the colon in assembly defm, I'm guessing it's tripping up over one of the sdcc peephole rules.

Posted: Sat Mar 05, 2016 12:11 am
by alvin
It's sdcc itself that's doing it even with the peepholer turned off. I'll have a look at the source and see if there's something there.

Posted: Sat Mar 05, 2016 12:25 am
by alvin
I'll just add the sdcc test case:

Code: Select all

extern int puts(const char *s);

int main()
{
        puts("Contact: xyz@da");
__asm
        .ascii "Contact: xyz@dd"
__endasm;

}
sdcc -mz80 -S --no-peep test.c

Code: Select all

_main::
;zz.c:6: puts("Contact: xyz@da");
        ld        hl,#___str_0
        push        hl
        call        _puts
        pop        af
;zz.c:9: __endasm;
                .ascii        "Contact:
        xyz@dd"
00101$:
        ret
___str_0:
        .ascii "Contact: xyz@da"
        .db 0x00

Posted: Sat Mar 05, 2016 12:53 am
by alvin
It's going to take someone more familiar with the sdcc lexer to fix:

https://sourceforge.net/p/sdcc/bugs/2479/

Posted: Sat Mar 05, 2016 6:11 am
by alvin
They've fixed it already. An updated zsdcc.exe for windows can be found here:

http://z88dk.cvs.sourceforge.net/viewvc ... _patch.zip