static char buf[50];
static char *buf_ptr;
void main()
{
buf_ptr = &buf[0]; // This does not find the
address of buf[0]
}
This section of code producess incorrect code.
; buf_ptr = &buf[0];
MOVLW _buf
MOVWF _buf_ptr
MOVLW (_buf + 1)
MOVWF (_buf_ptr + 1)
This find the low byte of the address OK but the high
byte of the address is worked out incorrectly.
sdcc -mpic14 -p16f627 test.c
Using sdcc v2.3.6 19 December 2003.
Logged In: YES
user_id=935049
changeing the code in genAddrOf() in src/pic/gen.c seams to
sort the bug out. Code changed to is below
static void genAddrOf (iCode *ic)
{
operand *result;
int size;
symbol *sym = OP_SYMBOL(IC_LEFT(ic));
pCodeOp *pcop0, *pcop1;
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
aopOp((result=IC_RESULT(ic)),ic,TRUE);
size = AOP_SIZE(IC_RESULT(ic));
// Assume that what we want the address of is in direct
addressing space
// Since there is no stack on the PIC
pcop0 = newpCodeOp(sym->rname, PO_IMMEDIATE);
PCOI(pcop0)->offset = 0;
PCOI(pcop0)->index = 0;
pcop1 = newpCodeOp(sym->rname, PO_IMMEDIATE);
PCOI(pcop1)->offset = 1;
PCOI(pcop1)->index = 0;
if (size == 2) {
emitpcode(POC_MOVLW, pcop0);
emitpcode(POC_MOVWF, popGet(AOP(result),0));
emitpcode(POC_MOVLW, pcop1);
emitpcode(POC_MOVWF, popGet(AOP(result),1));
} else {
emitpcode(POC_MOVLW, pcop0);
emitpcode(POC_MOVWF, popGet(AOP(result),0));
}
freeAsmop(result,NULL,ic,TRUE);
}
Logged In: YES
user_id=770505
fixed in CVS. I also fixed the same bug in pic16 port.
Logged In: YES
user_id=770505
fixed in CVS. I also fixed the same bug in pic16 port.