|
-
March 1st, 2006, 11:41 AM
#1
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 ?
-
March 1st, 2006, 12:59 PM
#2
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
-
March 1st, 2006, 03:47 PM
#3
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.
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:
requests for moving TTStr (which is a 4 bytes variable) to a one-byte register.
Thus, the compiler complains.
You may try something like:
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|