#1502 Bug in asm generated

closed-rejected
z80 port (188)
5
2013-05-25
2009-01-28
No

Hi,

I try to compile this C code:

void Pad_Refresh (void)
{
g_padFlags = g_padTable[Joystick_GetAxis (0)];
g_padFlags |= g_padTable[Joystick_GetAxis (1)];
if (Joystick_GetTrigger (0) || Joystick_GetTrigger (1)) g_padFlags |= PAD_BUTTON1;
//if (Joystick_GetTrigger (2) || Joystick_GetTrigger (3)) g_padFlags |= PAD_BUTTON2;
}

In this SDCC version:

SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.8.8 #5
350 (Jan 27 2009) (MINGW32)

And i obtain an error like this:

Error <a> machine specific addressing ...

due to:

or a,(#_g_padFlags+0)

this mnemonic is no Z80 compatible:
or r
or n
or (HL)
or (IX+d)
or (IY+d)

All the generated code here:

_Pad_Refresh_start::
_Pad_Refresh:
;..\msx\tools.c:712: g_padFlags = g_padTable[Joystick_GetAxis (0)];
ld a,#0x00
push af
inc sp
call _Joystick_GetAxis
inc sp
ld c,l
ld a,#<_g_padTable
add a,c
ld c,a
ld a,#>_g_padTable
adc a,#0x00
ld b,a
ld a,(bc)
ld hl,#_g_padFlags + 0
ld (hl), a
;..\msx\tools.c:713: g_padFlags |= g_padTable[Joystick_GetAxis (1)];
ld a,#0x01
push af
inc sp
call _Joystick_GetAxis
inc sp
ld c,l
ld a,#<_g_padTable
add a,c
ld c,a
ld a,#>_g_padTable
adc a,#0x00
ld b,a
ld a,(bc)
or a,(#_g_padFlags+0)
ld hl,#_g_padFlags + 0
ld (hl), a
;..\msx\tools.c:714: if (Joystick_GetTrigger (0) || Joystick_GetTrigger (1)) g_padFlags |= PAD_BUTTON1;
ld a,#0x00
push af
inc sp
call _Joystick_GetTrigger
inc sp
xor a,a
or a,l
jr NZ,00101$
ld a,#0x01
push af
inc sp
call _Joystick_GetTrigger
inc sp
xor a,a
or a,l
ret Z
00101$:
ld a,(#_g_padFlags+0)
or a,#0x10
ld hl,#_g_padFlags + 0
ld (hl), a
ret
_Pad_Refresh_end::
_g_padTable:
.db #0x00
.db #0x01
.db #0x09
.db #0x08
.db #0x0A
.db #0x02
.db #0x06
.db #0x04
.db #0x05

Discussion

  • Can you provide a complete, compileable example (i.e. including the declarations of variables and functions used) and the command line you use to compile?

    Thanks.

     
  • The code snipped provided is incomplete. I tried to reproduce the bug by adding these declarations:
    unsigned char g_padFlags;
    unsigned char *g_padTable;
    unsigned char Joystick_GetAxis(unsigned char);
    unsigned char Joystick_GetTrigger(unsigned char);
    #define PAD_BUTTON1 7
    #define PAD_BUTTON2 7
    and by trying to construct an example function myself, but didn't succeed.

    I thus cannot reproduce this bug using current sdcc.

    Philipp

     
    • milestone: --> unreproducable
    • assigned_to: nobody --> spth
    • status: open --> closed-rejected