#438 array index error

closed-fixed
z80 port (188)
5
2013-05-25
2003-01-17
Anonymous
No

bugs in the snapshot-versions ( tested with versions:
sdcc-snapshot-i586-mingw32msvc-20020823.zip
sdcc-snapshot-i586-mingw32msvc-20021229.zip
sdcc-snapshot-i586-mingw32msvc-20030110.zip )

1. c-source:

UCHAR DecodeBuffer[maxstore+1]; //first char is
counter
...
void COMDECO_1(UCHAR c){
DecodeBuffer[++DecodeBuffer[0]]= ((c>'9') ? (c-'7') &
0x5F :c-0x30)<<4;
}

2. wrong generated code with snapshot versions:

problem: ++DecodeBuffer[0]

; ---------------------------------
; Function COMDECO_1
; ---------------------------------
_COMDECO_1_start::
_COMDECO_1:
push ix
ld ix,#0
add ix,sp
; celdeco.c 135
; genPointerGet
ld hl,#_DecodeBuffer <---
ld l,(hl) <--- error
; genPlus
; genPlusIncr
ld c,l
inc c
; genAssign (pointer)
ld (hl),c <--- hl destroyed !!!
; genPlus
; Can't optimise plus by inc, falling back to the
normal way
ld a,#<_DecodeBuffer
add a,c
ld c,a
ld a,#>_DecodeBuffer
adc a,#0x00
ld b,a
; genCmpGt
; AOP_STK for
...

3. generated code with version 2.3.0 from 29.sept.2001

location ++DecodeBuffer[0]

; ---------------------------------
; Function COMDECO_1
; ---------------------------------
___COMDECO_1_start:
_COMDECO_1:
push ix
ld ix,#0
add ix,sp
; celdeco.c 135
; genPointerGet
ld hl,#_DecodeBuffer
ld c,(hl) <--- o.k
; genPlus
; genPlusIncr
inc c
; genAssign (pointer)
ld (hl),c <--- hl o.k
; genPlus
; Can't optimise plus by inc, falling back to the
normal way
ld a,#<_DecodeBuffer
add a,c
ld c,a
ld a,#>_DecodeBuffer
adc a,#0x00
ld b,a
; genCmpGt

4. the last version 2.3.0 works well at this place, but
have other problems e.g. all kinds of 8-bit-comparison
with "sbc xx"-instructions instead of "sub xx"

mailto:tbrinker@datus.com

Discussion

  • Johan Knol

    Johan Knol - 2003-01-24
    • assigned_to: nobody --> michaelh
     
  • Erik Petrich

    Erik Petrich - 2003-09-17

    Logged In: YES
    user_id=635249

    Recently fixed in src/z80/gen.c 1.117

     
  • Erik Petrich

    Erik Petrich - 2003-09-17
    • milestone: --> fixed
    • assigned_to: michaelh --> epetrich
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks