Pelles C forum
Pelles C => Bug reports => Topic started by: jj2007 on July 26, 2015, 09:37:19 AM
-
The push szTest works in MSVC but Pelles C throws an error:
#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:
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
-
Using Version 8.00.60 (Win64), this works OK:
#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:
char* szTest = "Hello World";
char* szFormat = "\n\n%s\n\n";
-
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.