前些天 帮一朋友测试代码,基于R8051,使用V4.02编译不报错误,使用V4.24.00.00报L121错误
*** ERROR L121: IMPROPER FIXUP
MODULE: .\BIN\main.obj (MAIN)
SEGMENT: ?PR?MAIN?MAIN
OFFSET: 00CEH
*** ERROR L121: IMPROPER FIXUP
MODULE: .\BIN\main.obj (MAIN)
SEGMENT: ?PR?MAIN?MAIN
对于L121,KEIL官网上给出的解释是这样的
*** Error L121 Improper Fixup
Module: filename (module-name)
Segment: segment-name
Offset: address
Description
After evaluation of absolute fix-ups, an address is not accessible. The improper address along with the specific module name, partial segment, and segment address are displayed. The fix-up command is not processed. This error occurs when an instruction tries do make a memory access that is outside the scope of this instruction (for example MOVX @Ri outside of the PDATA page, or ACALL outside of the 2KB code memory block).
调试代码,查看编译的汇编文件和映射文件,看到每一条指令都指向定义bdata的变量
OFDM_PHY_ext bit bdata bLib_RxPlcEnd;
OFDM_PHY_ext bit bdata RX_BUSY;
OFDM_PHY_ext bit bdata TX_BUSY;
Comm_ext bit bdata bCommRxEnd;
Comm_ext bit bdata bCommRxstart;
注释掉bdata,编译通过。说明不是软件本身的缺陷
查看帮助文件,查找bdata
一篇文章中这样写的
The variables ibase and bary are bit-addressable. Therefore, the individual bits of these variables may be directly accessed and modified. Use the sbit keyword to declare new variables that access the bits of bdata variables. For example:
sbit mybit0 = ibase ^ 0; /* bit 0 of ibase */
sbit mybit15 = ibase ^ 15; /* bit 15 of ibase */
sbit Ary07 = bary[0] ^ 7; /* bit 7 of bary[0] */
sbit Ary37 = bary[3] ^ 7; /* bit 7 of bary[3] */
The above example represents declarations, not assignments to the bits of the ibase and bary bdata variables. The expression following the carat symbol ('^') in the example specifies the position of the bit to access with this declaration. This expression must be a constant value.
The range depends on the type of the base variable included in the declaration. The range is:
0-7 for char and unsigned char, 0-15 for int, unsigned int,
short, and unsigned short, and
0-31 for long and unsigned long.
并没有定义bit类型的bdata。因此定义成char。
OFDM_PHY_ext char bdata bLib_RxPlcEnd;
OFDM_PHY_ext char bdata RX_BUSY;
OFDM_PHY_ext char bdata TX_BUSY;
Comm_ext char bdata bCommRxEnd;
Comm_ext char bdata bCommRxstart;
总结:
版本升级,对代码的规范性要求越来越严格。