#include <stdio.h>
#include <stdlib.h>
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
#ifdef _WIN32
typedef unsigned __int64 uint64;
#else
typedef unsigned long long uint64;
#endif
#define RSHIFT32(x, c) (uint32)((uint32)(x) >> (c))
#define RSHIFT64(x, c) (uint32)((uint64)(x) >> (c))
uint32 rshift32(uint32 x, uint8 c){return RSHIFT32(x, c);}
uint32 rshift64(uint32 x, uint8 c){return RSHIFT64(x, c);}
uint32 afterR32;
uint32 afterr32;
uint32 afterR64;
uint32 afterr64;
void TestShift(uint32 before, uint8 count)
{
afterR32 = RSHIFT32(before, count);
afterr32 = rshift32(before, count);
afterR64 = RSHIFT64(before, count);
afterr64 = rshift64(before, count);
}
int main(int argc, char* argv[])
{
uint32 before;
uint8 count;
if(argc != 3)
{
before = 0x80000000;
count = 0;
}
else
{
before = (uint32)atoi(argv[1]);
count = (uint8)atoi(argv[2]);
}
TestShift(before, count);
printf("RSHIFT32(0x%08x,%d)=0x%08x\n", before, count, afterR32);
printf("rshift32(0x%08x,%d)=0x%08x\n", before, count, afterr32);
printf("RSHIFT64(0x%08x,%d)=0x%08x\n", before, count, afterR64);
printf("rshift64(0x%08x,%d)=0x%08x\n", before, count, afterr64);
return 0;
}
for Release mode,
RSHIFT64(0x80000000,32)=0x80000000
rshift64(0x80000000,32)=0x80000000
for Release mode,
RSHIFT64(0x80000000,32)=0x00000000
rshift64(0x80000000,32)=0x00000000