位存取处理
//32位中八位处理部分四位处理,其他自己推算
//从32位整型中读取0-4位和读取4-8位;以下没有int4的转换,使用int8或其他代替都可以
#define READ_INT32_0_4_ARG(value) (int8)((int32)value >> 28 & 0x0000000f)
#define READ_INT32_4_8_ARG(value) (int8)(((int32)value << 4)>>28)
//对32位整型的前0-4位写入数据和前4-8位写入数据
#define WRITE_0_4_ARG_TO_INT32(srcValue,destValue) (int32)(((int32)destValue & 0x0fffffff) | ((int32)(srcValue & 0x0000000f) << 28))
#define WRITE_4_8_ARG_TO_INT32(srcValue,destValue) (int32)(((int32)destValue & 0xf0ffffff) | ((int32)(srcValue & 0x0000000f) << 24))
//32位中八位处理
//从32位整型中读取0-8位和读取9-16位和读取17-24位和读取25-32位
#define READ_INT32_0_8_ARG(value) (uint8)((uint32)value >> 24 & 0x000000ff)
#define READ_INT32_9_16_ARG(value) (uint8)(((uint32)value << 8 ) >> 24)
#define READ_INT32_17_24_ARG(value) (uint8)(((uint32)value << 16) >> 24)
#define READ_INT32_25_32_ARG(value) (uint8)((uint32)value & 0x000000ff)
//对32位整型的前0-8位和前9-16位和前17-24位和前25-32位写入数据
#define WRITE_0_8_ARG_TO_INT32(srcValue,destValue) (uint32)(((uint32)destValue & 0x00ffffff) | ((uint32)(srcValue & 0x000000ff) << 24))
#define WRITE_9_16_ARG_TO_INT32(srcValue,destValue) (uint32)(((uint32)destValue & 0xff00ffff) | ((uint32)(srcValue & 0x000000ff) << 16))
#define WRITE_17_24_ARG_TO_INT32(srcValue,destValue) (uint32)(((uint32)destValue & 0xffff00ff) | ((uint32)(srcValue & 0x000000ff) << 8))
#define WRITE_25_32_ARG_TO_INT32(srcValue,destValue) (uint32)(((uint32)destValue & 0xffffff00) | ((uint32)(srcValue & 0x000000ff)))
//32位中十六位处理
//从32位整型中读取0-16位和读取17-32位
#define READ_INT_0_15_ARG(value) (uint16)((uint32)value >> 16 & 0x0000ffff)
#define READ_INT_16_32_ARG(value) (uint16)((uint32) & 0x0000ffff)
//对32位整型的前0-16位和前16-32位写入数据
#define WRITE_0_15_ARG_TO_INT32(srcValue,destValue) (uint32)(((uint32)destValue & 0x0000ffff) | ((uint32)(srcValue & 0x0000ffff) << 16))
#define WRITE_16_32_ARG_TO_INT32(srcValue,destValue) (uint32)(((uint32)destValue & 0xffff0000) | ((uint32)(srcValue & 0x0000ffff)))
//64位中高低位处理
//从64位整型中读取低位和读取高位
#define READ_INT64_LOW(value) ((int32)((int64)value & 0x0000000fffffff))
#define READ_INT64_HIGH(value) ((int32)((int64)value >> 32)
//对两个32位整型进行合并成一个64位数
#define MERGE_INT32_TO_INT64(value1,value2) (int64)((int64)value1 << 32 | (int64)value2)
阅读(882) | 评论(0) | 转发(0) |