inline asm

Started by avcaballero, October 31, 2009, 07:35:51 PM

Previous topic - Next topic

avcaballero

Hello, I'm new in this forum. I'd like to ask you if I can write a messagebox in windows-c. Maybe something like this?

void writemessage(void)
{
  char msg[] = "Hello world!";
  char title[] = "from POASM";
  __asm {
    push   dword  0        // ok button
    push   dword  title
    push   dword  msg
    push   dword  0
    call   MessageBoxA
  }
  exit (0);
}

Thankx

Vortex

Hi avcaballero,

Here is how it should go :


#include <windows.h>
#include <stdio.h>

char msg[] = "Hello world!";
char title[] = "from Pelles C";

void WriteMessage(void)
{

__asm{
push 0
push OFFSET title
push OFFSET msg
push 0
call DWORD PTR MessageBox
}

}

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WriteMessage();
return 0;
}
Code it... That's all...

avcaballero

Hello. Thank you for your replay, it works fine. What I want now is to call a messagebox from c in an external PoASM module, adding it to the project.

Can I define in PoAsm the function MessageBox external?

POLINK: error: Unresolved external symbol '_MessageBox'.

Thank you

roosttylor

following message:
'polink fatal error(363): must be inside a section'.
This error is not listed in the Pelles C help file or in Goggle searches.
Please can anyone tell me the meaning of this error and what I need to do to resolve it?
Many thanks for your help.