unsigned char data[100]; unsigned char* datapos; #define ENT_DAT(_p) (*((unsigned int*)((unsigned char*)(_p) + 3))) void setFoo() { // this line goes wrong. the address generated should be // datapos -5 + 3 but you get datapos + 0x00FE (not 0xFFFE) ENT_DAT(datapos - 5) = 0xffff; } int main() { datapos = data + 5; setFoo(); return 0; }
code i get:
_setFoo: ;bug1.c:9: ENT_DAT(datapos - 5) = 0xffff; ld a,(#_datapos + 0) add a, #0xFE ld d,a ld a,(#_datapos + 1) adc a, #0x00 <<<<< is wrong, should be 0xff ? ld e,a ld l, d ld h, e ld (hl),#0xFF inc hl ld (hl),#0xFF ret _setFoo_end::
sdcc -v
SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08
3.3.0 #8604 (May 11 2013) (MINGW32)
more info contact,
hughserious@gmail.com
thanks,
-- hugh.
markdown fail.
try this:
#define ENT_DAT(_p) (((unsigned int)((unsigned char*)(_p) + 3)))
markdown fail again. too bad.
Using sdcc 3.3.2 #8930 I get:
error 10: 'lvalue' required for 'assignment' operation.
Which looks good to me.
Philipp
it's because the "*" were deleted by markdown, try this:
PS. i have 3.3.0, is there 3.3.2 anywhere to download.
thanks,
-- hugh.
unsigned char data[100];
unsigned char* datapos;
#define ENT_DAT(_p) (((unsigned int)((unsigned char*)(_p) + 3)))
void setFoo()
{
// this line goes wrong. the address generated should be
// datapos -5 + 3 but you get datapos + 0x00FE (not 0xFFFE)
ENT_DAT(datapos - 5) = 0xffff;
}
int main()
{
datapos = data + 5;
setFoo();
return 0;
}
On 29/12/2013 21:15, Philipp Klaus Krause wrote:
Last edit: Maarten Brock 2014-01-06
Just attach a file with compileable source. No use trying to get anything meaningful other than natural language across in the bug report itself.
Philipp
thanks. file attached.
On 29/12/2013 22:39, Philipp Klaus Krause wrote:
Thanks. I now see the issue in all ports I tried (z80, mcs51, stm8).
Philipp
P.S.: 3.3.2 is not a release. It is just the version reported by the current development verion.
Diff: