AnsweredAssumed Answered

__far increments only low order 16 bits

Question asked by Ron Wilson on Jul 27, 2011
Latest reply on Jul 27, 2011 by Ron Wilson

I am using CW 5.0 for S12X with a S12XE384

 

Far pointer variable defined as:

static unsigned int* __far adr;

In this loop:

while(adr < segEnd)

{

cs += *adr;

adr++;

}

The generated code is:

0072 fe0000   LDX   adr:1  0075 f60000   LDAB  adr  0078 5b10     STAB  16  007a 18ec31   GLDD  2,X+  007d f30000   ADDD  cs  0080 7c0000   STD   cs  0083 7e0000   STX   adr:1  008d 0705     BSR   *+7 ;abs = 0094  008f 22e1     BHI   *-29 ;abs = 0072  // other code  0094 fe0000   LDX   adr:1  0097 f60000   LDAB  adr  009a fd0000   LDY   segEnd:1  009d b60000   LDAA  segEnd  00a0 060000   JMP   _FPCMP

The generated code is not incrementing the high order byte of the far address.

 

Is this a compiler bug?

 

As a work-around, when I change the type of adr to be unsigned long (and add the apropriate type casts), the generated code does increment the high order portion of the address.

Outcomes