NO

Author Topic: Invalid combination of opcode and operands  (Read 3490 times)

Offline jj2007

  • Member
  • *
  • Posts: 536
Invalid combination of opcode and operands
« on: July 26, 2015, 09:37:19 AM »
The push szTest works in MSVC but Pelles C throws an error:

Code: [Select]
#include <stdio.h>

int main()
{

    char szText[20] = {0};
    char* szTest=  "Hello World";

    __asm
    {
            mov eax, szTest
            int 3
            push eax //works fine
            ; push szTest // error #3114: [asm] Invalid combination of opcode and operands
            pop eax

    }
}

Under the hood:
Code: [Select]
00401016                  ³.  C745 E8 00404000       mov dword ptr [ebp-18], offset 0040 ; ASCII "Hello World"
0040101D                  ³.  8B45 E8                mov eax, dword ptr [ebp-18]
00401020                  ³.  CD 03                  int 3
00401022                  ³.  50                     push eax


MichaelW

  • Guest
Re: Invalid combination of opcode and operands
« Reply #1 on: July 26, 2015, 11:39:56 AM »
Using Version 8.00.60 (Win64), this works OK:
Code: [Select]
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <windows.h>
int main(void)
{
    char* szTest[] = {"Hello World"};   
    char* szFormat[] = {"\n\n%s\n\n"};
    __asm
    {
        push    dword ptr szTest
        push    dword ptr szFormat
        call    printf
        add     esp, 8
    }
    _getch();
}
And also with:
Code: [Select]
    char* szTest = "Hello World";   
    char* szFormat = "\n\n%s\n\n";
« Last Edit: July 26, 2015, 11:44:46 AM by MichaelW »

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Invalid combination of opcode and operands
« Reply #2 on: July 26, 2015, 01:07:08 PM »
You are right, Michael. Pelles C just needs the dword ptr, which is not required with MSVC. Apparently Pelles C doesn't imply char pointer = dword.

Thanks for your efforts, and for clarifying this.