NEON函数详解------vcreate_u8 、vsetq_lane_s32、vgetq_lane_s32

#include

#include"stdio.h"

int main (void)

{


    int i;  


    uint8x8_t v; // define v as a vector with 8 lanes of 8-bit data

   

   unsigned char A[8]; // allocate memory for eight 8-bit data

  

   v = vcreate_u8(0x0102030405060708); // create a vector that contains the values

   // 1,2,3,4,5,6,7,8

  

  vst1_u8(A, v); // store the vector to memory, in this case, to array A

  

  for(i=0;i<8;i++)


   printf("%d ",A[i]);


   printf("\n");

  


   return 0;

}


结果:    8 7 6 5 4 3 2 1

功能介绍:

                   vcreate_u8():   在寄存器上面创建了8个数值。然后按照8位一取  取八次


#include "stdio.h"
#include

int main (void)
{
    int i;

    uint16x4_t v; // define v as a vector with 8 lanes of 8-bit data

    unsigned short A[4]; // allocate memory for eight 8-bit data

    v = vcreate_u16(0x00010002ffff0004); // create a vector that contains the values
                                 // 1,2,3,4

    vst1_u16(A, v); // store the vector to memory, in this case, to array A

    for(i=0;i<4;i++)

    printf("%d ",A[i]);

    printf("\n");

    return 0;
}
~                   
结果:    4 65535 2 1


   


   a=vsetq_lane_s32(data[0],a,0);
    a=vsetq_lane_s32(data[1],a,1);
    a=vsetq_lane_s32(data[2],a,2);
    a=vsetq_lane_s32(data[3],a,3);
    a=vaddq_s32(a,a);
    printf("B %d\n",vgetq_lane_s32(a,0));
    printf("B %d\n",vgetq_lane_s32(a,1));
    printf("B %d\n",vgetq_lane_s32(a,2));
    printf("B %d\n",vgetq_lane_s32(a,3));
    return 0;

 



你可能感兴趣的:(ARM架构下的neon技术简介)