Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#476 String gets lost if used in pointer array (mcs51 and ds390)

closed
Johan Knol
5
2013-05-25
2003-03-10
Jan Rejlek
No

If the string constants are used for initialization of
pointer array allocated in the code memory, then the
first string gets lost. If the pointer array is
allocated in data/xdata, all is O.K.

#include <stdio.h>

int disp(unsigned char i)
{
code char *code txt[] = {
"first",
"second",
"third"};

puts(txt[i]);
}

--------------------------
; genReceive
mov r2,dpl
;test1.c:10: puts(txt[i]);
; genMult
; genMultOneByte
mov b,#0x02
mov a,r2
mul ab
; genPlus
add a,#_disp_txt_1_1
mov dpl,a
mov a,b
addc a,#(_disp_txt_1_1 >> 8)
mov dph,a
; genPointerGet
; genCodePointerGet
clr a
movc a,@a+dptr
mov r2,a
inc dptr
clr a
movc a,@a+dptr
mov r3,a
; genCast
mov r4,#0x2
; genCall
mov dpl,r2
mov dph,r3
mov b,r4
lcall _puts
00101$:
ret
.area CSEG (CODE)
_disp_txt_1_1:
.byte __str_0,(__str_0 >> 8)
.byte __str_1,(__str_1 >> 8)
.byte __str_2,(__str_2 >> 8)
__str_1:
.ascii "second"
.db 0x00
__str_2:
.ascii "third"
.db 0x00
.area XINIT (CODE)

Regards,
Jan Rejlek

Discussion

  • Johan Knol
    Johan Knol
    2003-03-12

    • labels: --> C-Front End
    • milestone: --> fixed
    • assigned_to: nobody --> johanknol
    • status: open --> closed
     
  • Johan Knol
    Johan Knol
    2003-03-12

    Logged In: YES
    user_id=63512

    fixed in SDCCglue.c:1.135