1 #include<stdio.h>
2 #include<assert.h>
3 
main()4 int main()
5 {
6     int dsp_i, dsp_o;
7     int ccond_i, outflag_i, efi_i, c_i, scount_i, pos_i;
8     int ccond_o, outflag_o, efi_o, c_o, scount_o, pos_o;
9 
10     ccond_i   = 0x0000000C;  /* 4 */
11     outflag_i = 0x0000001B;  /* 3 */
12     efi_i     = 0x00000001;  /* 5 */
13     c_i       = 0x00000001;  /* 2 */
14     scount_i  = 0x0000000F;  /* 1 */
15     pos_i     = 0x0000000C;  /* 0 */
16 
17     dsp_i = (ccond_i   << 24) | \
18             (outflag_i << 16) | \
19             (efi_i     << 14) | \
20             (c_i       << 13) | \
21             (scount_i  <<  7) | \
22             pos_i;
23 
24     __asm
25         ("wrdsp %1, 0x3F\n\t"
26          "rddsp %0, 0x3F\n\t"
27          : "=r"(dsp_o)
28          : "r"(dsp_i)
29         );
30 
31     ccond_o   = (dsp_o >> 24) & 0xFF;
32     outflag_o = (dsp_o >> 16) & 0xFF;
33     efi_o     = (dsp_o >> 14) & 0x01;
34     c_o       = (dsp_o >> 14) & 0x01;
35     scount_o  = (dsp_o >>  7) & 0x3F;
36     pos_o     =  dsp_o & 0x1F;
37 
38     assert(ccond_o   == ccond_i);
39     assert(outflag_o == outflag_i);
40     assert(efi_o     == efi_i);
41     assert(c_o       == c_i);
42     assert(scount_o  == scount_i);
43     assert(pos_o     == pos_i);
44 
45     return 0;
46 }
47