Keil Logo

BL51: ERROR 121 (IMPROPER FIXUP)

QUESTION

I have a FIXUP error when I link my program.

*** ERROR 121: IMPROPER FIXUP
    MODULE:  C:\J1.OBJ (J1)
    SEGMENT: ?PR?MAIN?J1
    OFFSET:  0022

I have reduced my program to the following:

data int count;
idata char status[2];

void main (void)
  {
  char i;

  if (count < 261) count = 260;
  else if (count < 263)
    {
    i = status[count - 261];
    }
  }

What's wrong?

ANSWER

The above code appears as though it should work, but when you link it, the FIXUP error is generated. To find where the error occurs, check the OFFSET in the error message. In this case it is 0022 (Hex) in the J1.C file. If you look at the .LST file, you will see the following at this offset:

                                           ; SOURCE LINE # 12
0021 AF00    R     MOV     R7,count+01H
0023 7400    R     MOV     A,#status-0105H
0025 2F            ADD     A,R7
0026 F8            MOV     R0,A

Offset 0022 is where the compiler tries to calculate the offset of the status array minus the 261 that was used in the index.

    i = status[count - 261];

The problem with this is that status is an array in idata which is limited to 256 bytes in total space. Since the -261 is larger than a byte, the compiler/linker cannot resolve the address because the computed offset is 16-bits but the MOV instruction generated only allows for a byte.

To solve this problem requires a little creative type casting. The following code change solves the problem and generates the desired results:

    i = status[(unsigned char) count - (unsigned char) 261];

MORE INFORMATION

Last Reviewed: Tuesday, July 19, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.