#839 Z80 port produces wrong code

closed-fixed
z80 port (188)
5
2013-05-25
2004-11-27
Anonymous
No

I got two problems to compile attached code.
Both problems occured within put_digit function in the
source.
Now I makes work around with modifying my source to
avoid these problems. But I hope the problems will be
fixed.

Regards,
Naohiko Shimizu,
IP ARCH. Inc. http://www.ip-arch.jp/

void put_digit(unsigned char index, unsigned char dig) {
unsigned char i,j,org,off,idx,len,start;
struct CharGen *tbl;
unsigned char seg = SevenSegTbl[dig];
org=digit[index].origin;
off=digit[index].bit_off;
tbl=digit[index].tbl;
for(i=0;i<7;i++) {
len=tbl[i].Ylen;
start=tbl[i].Ystart;
if(seg&0x80) {
for(j=0;j<len;j++) {
idx = org+(start+j)*4;
vram[idx] |= tbl[i].Mask>>off;
if(off) {
vram[idx+1] |= tbl[i].Mask<<(8-off);
}
}
}
seg <<= 1;
}
}

1. Around label 00123$ in asm, generated variable
_put_digit_sloc1_1_0 loses syncronization to the
associates variable i. It is placed within a if statement,
and update of the variable does not occured every loops.

2. Around label 00124$ in asm, shift loop counter is
destroyed with shift taget value generation as following.

; genPointerGet
; AOP_STK for _put_digit_sloc4_1_0
ld a,(de)
ld -14(ix),a
; genRightShift
; AOP_STK for _put_digit_off_1_1
ld a,-4(ix)
inc a
; AOP_STK for _put_digit_sloc4_1_0
; AOP_STK for _put_digit_sloc2_1_0
ld a,-14(ix)
ld -12(ix),a
jp 00125$
00124$:
srl -12(ix)
00125$:
dec a
jp nz,00124$

Discussion

  • Nobody/Anonymous

    C and generated asm file

     
  • Erik Petrich

    Erik Petrich - 2004-12-07

    Logged In: YES
    user_id=635249

    fixed with src/SDCCloop.c 1.43 and src/z80/gen.c 1.138
    (SDCC version 2.4.7 #901)

     
  • Erik Petrich

    Erik Petrich - 2004-12-07
    • milestone: --> fixed
    • assigned_to: nobody --> epetrich
    • status: open --> closed-fixed
     

Log in to post a comment.