4 // 一つの32Bit整数に4つの8Bit整数を含めて取り出す
18 // int mask_4 = 0xff000000;
19 // int mask_3 = 0x00ff0000;
20 // int mask_2 = 0x0000ff00;
21 // int mask_1 = 0x000000ff;
23 // ab = ((a << 8) + b);
24 // abc = ((ab << 8) + c);
25 // abcd = ((abc << 8) + d);
28 // printf("a = %d, b = %d, c = %d, d = %d, ab = %d, abc = %d, abcd = %d\n", a, b, c, d, ab, abc, abcd);
29 // printf("ax = %x, bx = %x, cx = %x, dx = %x, abx = %x, abcx = %x, abcdx = %x\n", a, b, c, d, ab, abc, abcd);
31 // bar = ((abcd & mask_4) >> 24);
32 // printf("mask4 %x: %d\n", bar, bar);
34 // bar = ((abcd & mask_3) >> 16);
35 // printf("mask3 %x: %d\n", bar, bar);
37 // bar = ((abcd & mask_2) >> 8);
38 // printf("mask2 %x: %d\n", bar, bar);
40 // bar = (abcd & mask_1);
41 // printf("mask1 %x: %d\n", bar, bar);
53 int shift8_updown_out(int base, char ch)
56 int mask_to = 0xff000000;
57 int mask_mi = 0x00ff0000;
58 int mask_up = 0x0000ff00;
59 int mask_down = 0x000000ff;
63 if(base < 0){ base = 0; }
65 // 32ビット整数を右に24ビットシフトした位置を0にして8ビット整数を読む
67 ret = ((base & mask_to) >> 24);
69 // 32ビット整数を右に16ビットシフトした位置を0にして8ビット整数を読む
71 ret = ((base & mask_mi) >> 16);
73 // 32ビット整数を右に8ビットシフトした位置を0にして8ビット整数を読む
75 ret = ((base & mask_up) >> 8);
78 ret = (base & mask_down);