> Sanjiv Kumar Gupta wrote: > > > > What is stopping the value of 'foo' itself being > > 255? > > Programmer will get an overflow error for that > during linking. > > For my curiosity, what's the background here? Do you > really only have 256 > bytes of storage on this system? > That was just an example. We have an "segment_base+offset" insn with 16-bit offset.
> If you've got eight bit registers in a larger > address space then I'd expect > you'd want to address data outside the first 256 > bytes, e.g. you'd actually > want > > add r1, lowpart_offset(foo) > add r2, highpart_offset(foo) > > in which case > > add r1, lowpart_offset(foo + 10) > add r2, highpart_offset(foo + 10) > > would make sense. > > On the other hand, if you actually do only have 256 > bytes storage then you'd > want to the link to fail anyway because the hardware > won't cope - so the > overflow error is as good as anything else, isn't > it? > > Rup. > The problem at my hand is that the code like j = 10; // global main () { int i; i = a[j - 10]; } doesn't work with -O2 but it works without -O2. -O2 generates like add1 r1, segment_base, (a - 40) add2 r1, 40 Since 'a' is at the boundary of segment so 'a - 40' causes relocation overflow. But the same code works without -O2, because that generates code like add1 r1, segment_base, a add2 r1, -40 add2 r1, 40 So, all I want to do is don't allow 'a - 40' in 'add1' so that -O2 doesn't seem to be broken. thanks --Sanjiv > > > __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/