在 asm 中定义时处理数组以及从 c++ 传递到 asm 时,我有两个类似的问题。该代码内联工作正常,但我需要将它们与 cpp 分离到一个 asm 文件中。编译器可能不会抛出错误或警告,但每次运行的最终结果都是随机的,并且应该像内联时一样保持不变。
以下代码在 MMX ( movq mm6,twosMask_W
) 中使用时有效,但我需要 SSE2 的等效代码。我认为这会起作用,但我似乎不正确。
.data
align 16
twosMask_W qword 2 dup(0002000200020002h)
.code
...
movdqa xmm6,oword ptr twosMask_W
...
第二个问题是当我将thresh128
数组从 C++ 传递到 asm 时(同样适用于 SSE2):
//C++
uint64_t thresh128[2];
thresh128[0] = ((thresh-1)<<8)+(thresh-1);
thresh128[0] += (thresh128[0]<<48)+(thresh128[0]<<32)+(thresh128[0]<<16);
thresh128[1] = thresh128[0];
sendToASM(thresh128)
//ASM
;There are more parameters that utilize the registers but not listed.
receivedFromCPP proc thresh:qword
public receivedFromCPP
...
movdqu xmm4,oword ptr thresh
...
我尝试在过程中将 thresh 作为 oword 参数,但没有产生任何结果。我确定我有一些语法或参数类型错误。任何帮助将不胜感激。
注意:在 VS2013 for x86 中使用 MASM 编译。