CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Posts
    31

    assembly block code Error ?

    Inside function :

    TCHAR TStr[100];
    TCHAR *TTStr=TStr;

    *1)
    __asm {
    mov AL,[TStr];
    }

    *2)
    __asm{
    mov AL,[TTStr];
    }


    *1) is works.
    *2) didn't work, It's said error C2443 : operand size conflict.

    why *2) doesn't works ?

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: assembly block code Error ?

    I don't use assembly much, but my guess is that the issue is that 'TStr' is actually "sizeof(TCHAR)*100" bytes, and 'TTStr' is only 4 bytes (on a 32 bit machine).

    However, I don't know what AL is....

    Viggy

  3. #3
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: assembly block code Error ?

    sizeof(TCHAR)==1 when compiling a non-unicode project, which means that a TCHAR contains 1 byte.
    AL contains one byte.

    Code:
    mov AL,[TSTR]
    Works, because it is equivalent to:
    Code:
    mov AL, byte ptr [(offset TStr)]
    That is, it moves the first byte of the array into AL.

    But:
    Code:
    mov AL,[TTStr]
    requests for moving TTStr (which is a 4 bytes variable) to a one-byte register.
    Thus, the compiler complains.
    You may try something like:
    Code:
    mov EAX, [TTStr]
    In that case, the whole pointer will be copied to the EAX register.
    And the lowest byte is stored in AL.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured