1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include <stdio.h>
- unsigned getbits(unsigned x, int p, int n);
- unsigned int setbits(unsigned int x,unsigned int p,unsigned int n,unsigned int y);
- #define MAGIC_NUMBER 33091
- void shotgunPrintUint(const char name[], unsigned int in);
- unsigned int invertBits(unsigned int x,unsigned int p,unsigned int n);
- unsigned getInvertBits(unsigned x, int p, int n);
- int rightrot(int in, int rots);
- int main()
- {
-
- shotgunPrintUint("return ",rightrot(0xdeadbeef,8));
- // printf("i:%u \t temp:%x \n",-1,temp);
- /** shifting 32 bits out is an overflow condition .*/
- // unsigned int temp = ~0;
- // unsigned int temp2=temp<<32;
- // printf("\t temp:%x \n",temp2);
- return(0);
- }
- int rightrot(int in, int rots)
- {
- return in >> rots;
- }
- /**
- caution if you printf, padded with 0's, a hex number of exactly 0 it will print
- as 0000000000 not 0x00000000
- */
- /**
- drop me in if you don't want to use a debugger like GDB to shotgun-debug
- print the value of a uint
- */
- void shotgunPrintUint(const char name[], unsigned int in)
- {
- printf(name,23423);
- printf("\t\t: %0#10x \n",in);
- return;
- }
|