Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mov or movq ?

1,179 views
Skip to first unread message

Starbuck

unread,
Feb 26, 2009, 4:54:42 AM2/26/09
to
hi,
this code compiled with VC6 but not with VC8 nor VC9 (see below)
not a champion at x86 assembly,
I guess changing movq with mov
may do same thing,
am I right ?


1>.\ResizeFrame.cpp(1607) : error C2415: improper operand type
movq [edi], xmm0
1>.\ResizeFrame.cpp(1614) : error C2415: improper operand type
movq [edi], xmm0
1>.\ResizeFrame.cpp(1646) : error C2415: improper operand type
movq [edi], xmm0


//----------------------------------------------------------------
void* memsetP4(void* pDest, int byte_val, size_t cbSize)
//----------------------------------------------------------------
{
size_t cbLeadMain, cbLeadLead, cbMain, cbTrailMain, cbTrailTrail;

__asm
{
//if (cbSize < 8)
//{
// return memcmp(pDest, pSrc, cbSize); // std intrinsic function
//}
mov ecx, cbSize // ecx = cbSize
cmp ecx, 32
mov edi, pDest
jb l_memset

movd xmm0, byte_val
punpcklbw xmm0, xmm0
pshuflw xmm0, xmm0, _MM_SHUFFLE(0,0,0,0);

//cbLead = ((((long)pDest) + 31) & ~31) - (long)pDest;
lea eax, [edi + 31]
and eax, ~31
sub eax, edi // eax = cbLead

sub ecx, eax // cbSize (ecx) -= cbLead

//cbLeadMain = cbLead & ~7;
mov edx, eax // edx = cbLead
and eax, ~7 // eax = cbLeadMain
mov cbLeadMain, eax

//cbLeadLead = cbLead - cbLeadMain;
sub edx, eax // ecx = cbLeadLead
mov cbLeadLead, edx
/*ASSERT(cbLeadLead > cbSize);*/ // since cbSize >= 0 && cbLeadLead
< 8

//cbTrail = cbMain = cbSize - cbLead;
mov eax, ecx // eax = cbSize
and ecx, 63 //
sub eax, ecx // cbTrail = cbSize & 63

mov cbMain, eax // cbMain = cbSize - cbTrail

//cbTrailMain = cbTrail & ~7;
mov edx, ecx // edx = cbTrail
and ecx, ~7 // ecx = cbTrailMain
mov cbTrailMain, ecx

//cbTrailTrail = cbTrail - cbTrailMain;
sub edx, ecx // edx = cbTrailTrail
mov cbTrailTrail, edx

// main part
starts ----------------------------------------------------
mov ecx, cbLeadLead
mov eax, cbLeadMain

test ecx, ecx // cbLeadLead? // this jump can be removed
jz l_leadloop
movq [edi], xmm0
add edi, ecx

l_leadloop:
sub eax, 8
jl l_startmainloop

movq [edi], xmm0
add edi, 8
jmp short l_leadloop

l_startmainloop:
mov ecx, cbMain
test ecx, ecx // cbMain?
jz l_starttrailloop

//l_startlargemainloop:
punpcklqdq xmm0, xmm0

l_alignedmainloop:
movntdq [edi + 0], xmm0
movntdq [edi + 16], xmm0
movntdq [edi + 32], xmm0
movntdq [edi + 48], xmm0

add edi, 64
sub ecx, 64
ja l_alignedmainloop

sfence // only needed after movntdq

l_starttrailloop:
mov eax, cbTrailMain
mov ecx, cbTrailTrail // remove if no cbTrailTrail test
below

l_trailloop:
sub eax, 8
jl l_trailtrail

movq [edi], xmm0
add edi, 8
jmp short l_trailloop

l_trailtrail:
test ecx, ecx // cbTrailTrail? // this test can be removed
jz l_finish
// fall through to l_memset

l_memset:
mov eax, byte_val
rep stosb

l_finish:
//emms
}

return pDest;
}

Kiuhnm

unread,
Feb 27, 2009, 3:20:53 PM2/27/09
to
Starbuck wrote:
> hi,
> this code compiled with VC6 but not with VC8 nor VC9 (see below)
> not a champion at x86 assembly,
> I guess changing movq with mov
> may do same thing,
> am I right ?
>
>
> 1>.\ResizeFrame.cpp(1607) : error C2415: improper operand type
> movq [edi], xmm0
movq qword ptr [edi], xmm0

> 1>.\ResizeFrame.cpp(1614) : error C2415: improper operand type
> movq [edi], xmm0

movq qword ptr [edi], xmm0

> 1>.\ResizeFrame.cpp(1646) : error C2415: improper operand type
> movq [edi], xmm0

movq qword ptr [edi], xmm0

Kiuhnm

Starbuck

unread,
Mar 3, 2009, 2:41:10 PM3/3/09
to
This doesn't work:

error C2400: inline assembler syntax error in 'opcode'; found 'qword'


movq qword ptr [edi], xmm0

Jim

"Kiuhnm" <spam...@crayne.org> a écrit dans le message de
news:49a84b27$0$835$4faf...@reader5.news.tin.it...

Kiuhnm

unread,
Mar 4, 2009, 12:11:33 PM3/4/09
to
Starbuck wrote:
> This doesn't work:
>
> error C2400: inline assembler syntax error in 'opcode'; found 'qword'
> movq qword ptr [edi], xmm0
>
> Jim

That's weird.
I can compile the following code in VC9:

void f()
{
__asm movq qword ptr [edi], xmm0
}

Without "qword ptr" it tells me "improper operand type".

Kiuhnm

Starbuck

unread,
Mar 7, 2009, 12:34:08 PM3/7/09
to
You're right, even in the other direction:

movq xmm2, qword ptr [edx] compiles :- )

(I was doing "movq qword ptr xmm2, [edx]" which sure is non sense, too
tired).

THANKS A LOT !

"Kiuhnm" <spam...@crayne.org> a écrit dans le message de

news:49aeb653$0$838$4faf...@reader5.news.tin.it...

0 new messages