sdcc compile mangles defm

Bug reports (if you don't/won't have a Github account)
Post Reply
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

sdcc compile mangles defm

Post 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.
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post 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.
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post 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
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

It's going to take someone more familiar with the sdcc lexer to fix:

https://sourceforge.net/p/sdcc/bugs/2479/
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post 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
Post Reply