等效于_mm_set_epi8的带参数的参数

问题描述 投票:1回答:1

我正在编写一个程序以通过大学的科目考试,该程序应比较C ++和SIMD函数与汇编函数的效率。现在,我设法很好地完成了第一个,但是在第二个过程中,我发现了一个问题:

在我的C ++函数中,我有一行这样的代码:

XXX_R0 = _mm_set_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RedForAll);

其中RedForAll在我的函数的参数中给出:

void CppSIMDFunction(unsigned char *src, short RedForAll, short GreenForAll, short BlueForAll)

我考虑过这样分配内存:

.DATA
Red db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X

然后以某种方式将RedForAll保存在标有X的位置,但是该怎么做?恐怕在这种情况下LDR不会有用,因为我需要在特定的位置将值从寄存器加载到内存中,那么如何实现呢?

assembly x86 sse simd
1个回答
0
投票

[适当使用零扩展后使用movd(使用SSE时)或vmovd

; assuming RedForAll is in cl
movzx eax, cl     ; zero extend al into eax
movd xmm0, eax    ; copy eax into xmm0 and clear the upper 96 bits
© www.soinside.com 2019 - 2024. All rights reserved.