O HAI THIS BLOG PURPZIEZ 2 B UZED AZ MAH PLESIOUS MEM. :)

2007/10/26

JunkCode.karma++; /* br10_stim.c */

問題: このコードは何でしょう? :9
[Q. This code for what? :9]
#include <stdio.h>
#include <stdint.h>

#define MSK16(i, b) ((i) & ((uint16_t)0x0001 << (b)))
#define SLL16(i, b) ((uint16_t)(i) << (b))
#define SLR16(i, b) ((uint16_t)(i) >> (b))
#define ORG16(i, b) (SLR16(MSK16((i), (b)), (b)))
#define MOV16(i, b1, b2) (SLL16(ORG16((i), (b1)), (b2)))

uint16_t br10(uint16_t i) {
uint8_t b;
uint16_t bri;

for (bri = 0x0000, b = 0; b < 10; b++) {
bri |= MOV16(i, b, (10 - 1) - b);
}

return bri;
}

int main(int argc, char *argv[]) {
uint16_t i, bri, brbri;

for (i = 0x0000; i < SLL16(0x0001, 10); i++) {
bri = br10(i);
brbri = br10(bri);
printf("%4d <-BR10-> %4d <-BR10-> %4d ... %s\n",
i, bri, brbri, (i == brbri) ? "OK" : "NG");
}

return 0;
}

0 件のコメント: