Tool/software: TI C/C++ Compiler
When I try to add an unsigned long to a pointer, the compiler outputs assembly code that treats the offset as if it were an signed int.
unsigned long len;
const unsigned char* ptr;
/* code*/
ptr+=len;
/*code*/
In the assembly it has the high word of len R6 and the low word in R10, and it’s storing ptr in R5
The line ptr+=len; is being translated to:
MOVA R10, R15
RLAM.A #4,R15
RRAM.A #4,R15
ADDA R15,R5
This truncates and then sign extends len. Is there any way to declare len such that it could be the same size as a pointer (20 bits) and have it avoid the shifts?
This is for some bootloading code that is reading and writing code memory in a project that's otherwise only playing with data in RAM. So I would prefer to not have to switch to a large data model.
I'm using compiler 4.4.2