News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Problem with compiling inline ASM in VC++ 6?

Started by ngxfer001, March 13, 2006, 07:36:04 AM

Previous topic - Next topic

ngxfer001

Hi Experts,

I have limited knowledge about ASM. Recently, I am trying to compile a video codec VP31 source code and part of their algorithm is using ASM.

I am using the VC++ 6 and I have installed the service pack 5 (downloaded from MS). I have also installed the processor pack and obtain a copy of iaxmm.inc.

When I try to compile, it gives me 102 errors. I analysis these errors and it seems to me that all of them are complaining the same problem.

A code segment is shown below:

NT32 WmtGetHalfPixelSAD( UINT8 * SrcData, UINT8 * RefDataPtr1, UINT8 * RefDataPtr2, UINT32 PixelsPerLine, INT32 ErrorSoFar, INT32 BestSoFar );

The inline code segment are:

__asm
{

mov eax, dword ptr [SrcData] // Get Src Pointer
pxor xmm6, xmm6 // clear mm6

mov ebx, dword ptr [RefDataPtr1] // Error!!!!!
pxor xmm7, xmm7

mov edx, dword ptr [PixelsPerLine] // Error!!!!!
mov ecx, dword ptr [RefDataPtr2]

mov esi, edx // width
add edx, STRIDE_EXTRA // Src Pitch

// Row 1 and 2
movq xmm1, QWORD ptr [ebx] // Error!!!!
movq xmm2, QWORD ptr [ecx] // Eight Bytes from ref 2


The error are:
C:\Documents and Settings\ferdinandn\My Documents\Visual Studio 2005\Projects\vp32\CoreLibs\CDXV\Vp31\cx\Win32\CWmtFunctions.c(124) : error C2415: improper operand type

It seems to me that the error are cause by unrecongnized of ebx, edx etc. Can someone please help me out and give me a hint on what is the error?? Thank you thank you very much.

Thank you for reading this post.

Best Regards
Ferdinand

hutch--

Ferdinand,

It has nothing to do with the registers you mentioned, its what you are trying to stuff into them. We would at least need to see the complete inline asm section,


__asm {

    ; all of the asm code

    }


and have some grasp of what the data was you are trying to load.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark Jones

Quote from: ngxfer001 on March 13, 2006, 07:36:04 AM
mov ebx, dword ptr [RefDataPtr1] // Error!!!!!
movq xmm1, QWORD ptr [ebx] // Error!!!!

Hello Ferdinand,

These appear correct in syntax as Hutch says. It sounds as if RefDataPtr1 and whatever pointer EBX is set from, are not being defined properly by the compiler. Perhaps check your includes for this file?

Question, is this the so-called "libtheora" codec from http://www.theora.org/ ? Perhaps that is newer than your source. They also might be able to help you on their mailing list, see http://www.theora.org/lists.html
Good luck! :bg
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

ngxfer001

Hi Hutch,

I am sorry I didn't provide enough information. The previous code was too long, so I found a more meaningful code to demonstrate the problem.

/****************************************************************************
*
*  ROUTINE       :     WillametteNewInstructionOSSupport()
*
*  INPUTS        :    
*
*  OUTPUTS       :    
*
*  RETURNS       :     retrun true if the OS support willamette new
*                  instructions, return false otherwise
*                  
*
*  FUNCTION      :     detect willamette processor
*
*  SPECIAL NOTES :     None.
*
*  ERRORS        :     None.
*
****************************************************************************/
int   WillametteNewInstructionOSSupport()
{
   __try
   {
      __asm xorpd   xmm0, xmm0     // Error
   }
   __except(EXCEPTION_EXECUTE_HANDLER)
   {
      if(_exception_code())
      {
         return 0;
      }
      return 0;
   }
   return 1;
}

as I continue to analysis the problem, I found that the error was causing by xmm0~7 registry in the inline code section. I have asm file that using the xmm0~7 and they compiled perfectly.

I then read up the MSDN, it seems to me that the asm file is compiled by MASM and the inline assmebler is build in the compiler. This seems that the processor pack is linked 100% to the MASM but the C++ compiler did not link to it. That explain why the inline assmembler complain and the ASM file is fined.

C:\Documents and Settings\ferdinandn\My Documents\Visual Studio 2005\Projects\vp32\CoreLibs\CpuID\Win32\Wmt_CpuID.cpp(136) : error C2400: inline assembler syntax error in 'opcode'; found 'xmm0'

Thank you for your help.

Best Regards
Ferdinand


ngxfer001

Hi Mark Jones,

I have e-mail them already but hasn't got any reply yet. As seems to me now that it is more likely the setup problem, I will e-mail them too for the updated information.

Thank you for your help.

Best Regards
Ferdinand

ngxfer001

Hi experts,

Just to add more information. I am newbie to this and I might setup incorrectly. When I install the processor pack, do I need to do some special configuration in the project setting to allow the inline assembler to recoginze the processor pack.

Please help me, I stuck in this problem for the weekend (no holiday >.<,).

Thank you for your replys.

Best Regards
Ferdinand

ngxfer001


Mincho Georgiev

Hii, ngxfer001.
You're not using 64-bit cl.exe, are you ?

hutch--

Ferdinand,

The inoine assembler built into CL.EXE has NOTHING to do with the processor pack or ML.EXE. What you need to be checking is the actualy syntax in relation to the documentation of the C compiler. If its not recognising XMM instructions, you may have a project setting that is excluding them on a processor basis. I would also check your build options to make sure you have not excluded XMM instructions.

You will need to make sure it CAN build XMM instructions as its an old C compiler and the /G6 option may not do the job.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ngxfer001

Hi Shaka_zulu,

I am newbie, so I don't know how to check if I am using the 64-bit cl.exe? can you teach me how to check that.

Hi Hutch,

I think I see /G6 in the project setting. I am just using the come along project setting since I don't know how to set it. The project setting is follows:

/nologo /G6 /MTd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I "..\..\..\Include" /I "Include" /I "..\..\..\Include\VP31" /I "..\..\Include\VP31" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VP31VFW_EXPORTS" /D "VP30_COMPRESS" /D "DXV_DECOMPRESS" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c

which is using /G6. So if not using /G6, what should I change to make it compiled. Sorry. I am really lack of experience in this field.

Thank you for reading this message.

Best Regards
Ferdinand

ngxfer001

Sorry, just add more information.

I am very sure that it doesn't recognize the XMM0~7.

Thank you very much
Best Regards
Ferdinand

hutch--

Try building it with the version of CL.EXE that comes with the VCTOOLKIT2003 as its about 5 years later and has a higher build option.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ngxfer001

Thanks Hutch,

I am download the VCTOOLKIT2003 now. I hope this solve my problem.

If I download and install the VCTOOLKIT2003, should I just install it and the VC++ 6 IDE will use the newer cl instead of the old one??

Best Regards
Ferdinand

ngxfer001

Just add one more question,

Why other people can compile it with the VS6 + processor pack?? and I can't?

Best Regards
Ferdinand Ng

ngxfer001

Hi Hutch,

After using the VS2003.net toolkit, the compiler complains about the C:\VPVISION0.5_SOURCE\DUCKSOFT\DXV_NEW\INCLUDE\iaxmm.inc(33) : error A2008: syntax error : TEXTEQU

It doesn't recognize the TEXTEQU??

The code segment is:
XMMWORD TEXTEQU   <DWORD>

Is it because the performance pack? cause the performance pack copy some stuff into the VC98\bin folder, now what I do is point the IDE to use the VS2003NETTOOLKIT folder.

Best Regards
Ferdinand