ICC inline assembler doesn`t like push/pop

2019-08-11 00:17发布

问题:

I try to excute assembler inline with icc in msasm:

int main (void)
{
  __asm{
    mov eax, 5h;  //works
    push eax;     // after shell command /opt/intel/bin/icc -use_msasm asm.c:
                  // asm.c(7): (col. 5) error: Unsupported instruction form in asm                          
                  // instruction push.

   //pop ebp;    // the same 
        };

printf("success!\n");
return 1;
}

Does anybody know why icc doesn`t accept push and pop?

Thanks in advance!

回答1:

You should use x64 version of registers instead. So the correct version should like this:

__asm{
    mov rax, 5h;
    push rax;
};

Also, pay attention to architecture differences when dealing with pointers, 0x8*******, etc. You should never use batch Find and Replace without reading your inline first.