I was doing some digging in the SDCC source (stm8/gen.c) to see if I
could find where these LDW instructions were generated, and found the
following instances of var+offset pattern:
Line 456: SNPRINTF (buffer, sizeof(buffer), "#((%s + %d) >>
%d)", aop->aopu.immd, aop->aopu.immd_off, offset * 8);
Line 500: SNPRINTF (buffer, sizeof(buffer), "#((%s + %d) >>
%d)", aop->aopu.immd, aop->aopu.immd_off, offset * 8);
Line 502: SNPRINTF (buffer, sizeof(buffer), "#(%s + %d)",
aop->aopu.immd, aop->aopu.immd_off);
Line 7969: emit2 ("ldw", "y, #%s+%ld", sym->rname,
(long)(operandLitValue (right)));
Line 7993: emit2 ("ldw", "x, #%s+%ld", sym->rname,
(long)(operandLitValue (right)));
The first is in aopGet(), the next two in aopGet2() and the last two in
genAddrOf(). I'm not sure how aopGet* relate to my example cases, but
it's obvious the first case is indeed emitted by genAddrOf(), so I would
guess the other case is probably from aopGet2().
I don't think it's helpful that separate parts of the code can generate
different formatting for what ends up as the same instruction. Like I
said earlier, it makes writing peephole optimiser rules needlessly
difficult when there are such inconsistencies. Is it worth filing a bug
report to address this?
Regards,
Basil Hussain
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user