Further simplified: #include <cc1110.h> __xdata struct { unsigned char* a; unsigned int b; } foo; struct { unsigned char c; } bar; int main() { unsigned int len = ADDR << 8; __xdata unsigned char* ptr = &foo.a[0] + foo.b; bar.c = (unsigned int)ptr; if (len + foo.b > 516) len = 516 - foo.b; foo.b += len; return 0; } This produces the following: ; bug3381.c:19: foo.b += len; mov a,_main_len_65536_1 add a,r7 mov r6,a mov a,(_main_len_65536_1 + 1) addc a,r6 mov r7,a mov dptr,#(_foo + 0x0003) mov a,r6...
Further simplified: #include <cc1110.h> __xdata struct { unsigned char* a; unsigned int b; } foo; struct { unsigned char c; } bar; int main() { unsigned int len = ADDR << 8; __xdata unsigned char* ptr = &foo.a[0] + foo.b; bar.c = (unsigned int)ptr; if (len + foo.b > 516) len = 516 - foo.b; foo.b += len; return 0; } ; bug3381.c:19: foo.b += len; mov a,_main_len_65536_1 add a,r7 mov r6,a mov a,(_main_len_65536_1 + 1) addc a,r6 mov r7,a mov dptr,#(_foo + 0x0003) mov a,r6 movx @dptr,a mov a,r7 inc dptr...
I was able to distill the problematic code down to this single file which still demonstrates the issue (with SDCC 4.2.0 #13081): #include <cc1110.h> SFRX(USBCNTL, 0xDE16); SFRX(USBCNTH, 0xDE17); typedef struct { unsigned int event; } USB_STATE; typedef struct { unsigned char* OUTbuf; unsigned int OUTlen; unsigned int OUTbytesleft; volatile unsigned char flags; } USB_EP_IO_BUF; typedef struct DMA_DESC_S { unsigned char destAddrH; unsigned char destAddrL; } DMA_DESC; USB_STATE usb_data; __xdata USB_EP_IO_BUF...
I was able to distill the problematic code down to this single file which still demonstrates the issue (with SDCC 4.2.0 #13081): #include <cc1110.h> SFRX(USBCNTL, 0xDE16); SFRX(USBCNTH, 0xDE17); typedef struct { unsigned int event; } USB_STATE; typedef struct { unsigned char* OUTbuf; unsigned int OUTlen; unsigned int OUTbytesleft; volatile unsigned char flags; } USB_EP_IO_BUF; typedef struct DMA_DESC_S { unsigned char destAddrH; unsigned char destAddrL; } DMA_DESC; USB_STATE usb_data; __xdata USB_EP_IO_BUF...
Konstantin Kim: Did you check out revision 7106b017cc1568b451410a4e23a7aa3b83c07b7b of rfcat before compiling? The master branch has a workaround which marks ep5.OUTlen as volatile to prevent it from being cached to registers.
Incorrect compilation starting in r10263