I have this function that works fine with a number of 32bit c compilers including gcc 4.5.2
It fails with all gcc versions 4.6.2 and later.
I believe the offending line is:

          __asm__("pushl %0" : : "r" (arg));

I am not familiar with at&t assembler syntax at all.
Is there an alternative with the later compilers?
The code is not mine so it's functionality might be questionable as in is there an alternative approach?

Thank you for your time

James


int BCX_DynaCallB (char *FuncName, char *DllName, int nArgs, ...)
{
  register int i;
  HINSTANCE  hInst=0;
  DYNACALL1 lpAddr=0;
  int arg, result =0;
  int *argtable = (int*)malloc(nArgs * sizeof *argtable);
  char buff[256];
  va_list ap;

  hInst=GetModuleHandle(DllName);
  if(hInst==NULL)
  {
      hInst=BCX_LoadDll(DllName);
  }
  lpAddr=(DYNACALL1)GetProcAddress(hInst,FuncName);
  if(lpAddr==NULL)
    {
      sprintf(buff,"%s%s",FuncName,"A");
      lpAddr=(DYNACALL1)GetProcAddress(hInst,buff);
    }
  if(lpAddr==NULL)
    {
      sprintf(buff,"%s%s","_",FuncName);
      lpAddr=(DYNACALL1)GetProcAddress(hInst,buff);
    }
  if (lpAddr)
    {
      va_start(ap,nArgs);
      for (i=0; i<nArgs;i++)
        {
          argtable[i] = va_arg(ap,int);
        }
      va_end(ap);
      while (--nArgs >= 0)
        {
          arg = argtable[nArgs];
          #if defined( __LCC__ )
          _asm("pushl %arg")
          #elif defined( __MINGW32__ ) || defined( __TINYC__)
          __asm__("pushl %0" : : "r" (arg));
          #elif defined( __BCPLUSPLUS__ ) 
            asm push arg
          #else
          __asm{push arg}
          #endif
        }
      result = (int)lpAddr();
  }
  free(argtable);
  return result;
}