一 汇编代码
global Add
Add:
movdqa xmm0, [rdi]; //第一个数组载入XMM0寄存器
movdqa xmm1, [rsi]; //第二个数组载入xmm1寄存器
paddb xmm0, xmm1;//加起来
movdqu [rdx], xmm0;// 载出到第三个数组
二 C语言代码
#include <stdio.h>
#include <string.h>
extern void Add(unsigned char *a, unsigned char *b, unsigned char *c);
int main()
{
char a[16], b[16], c[16];
memset(a, 0x01, 16);
memset(b, 0x02, 16);
memset(c, 0x0, 16);
Add(a, b, c);
for (int i = 0; i < 16; i++)
printf("%d ", c[i]);
return 0;
}
三 输出
test# ./addTest
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3