开发者

GCC warning: non-pic addressing form not suitible for pic code

The following code compiles fine in MSVC, but GCC gives a warning, which really bugs me: non-pic addressing form not suitible for pic code.

Can you please tell me the cause of this warning and how to fix it if it really is a potential problem? I am using -fasm-blocks compiler option to enable intel style assembly, adding -fpic argument makes no difference.

unsigned short dataMask[] = {0x0ffff, 0x07bef, 0x039e7, 0x018e3, 0x0861, 0x020, 0,0};

void test
{
    _asm
    {
        xor     ecx, ecx // ecx == 0
        //...
        // value in ecx may change
        //...
        mov     bx, [dataMask + ecx * 2]
        //...
 开发者_如何转开发   };
}


GCC is trying to tell you that [dataMask + ecx * 2] isn't a valid addressing mode. This is due to the PIC's nature: it is a RISC, and you're writing RISC code with CISC syntax, not a good idea IMO. Basically, the x86 has a way more complete (and complicated) instruction set, while the PIC's one isn't so extended. I'm quite tired right now, but I hope I was clear ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜