1 /* i/n/x.h
2 **
3 ** This file is in the public domain.
4 */
5   /**  Constants.
6   **/
7     /* Conventional axes for gate call.
8     */
9 #     define u3x_pay      3       //  payload
10 #     define u3x_sam      6       //  sample
11 #       define u3x_sam_1  6
12 #       define u3x_sam_2  12
13 #       define u3x_sam_3  13
14 #       define u3x_sam_4  24
15 #       define u3x_sam_5  25
16 #       define u3x_sam_6  26
17 #       define u3x_sam_12 52
18 #       define u3x_sam_13 53
19 #       define u3x_sam_7  27
20 #       define u3x_sam_14 54
21 #       define u3x_sam_15 55
22 #     define u3x_con      7       //  context
23 #     define u3x_con_2    14      //  context
24 #     define u3x_con_3    15      //  context
25 #     define u3x_con_sam  30      //  sample in gate context
26 #     define u3x_bat      2       //  battery
27 
28 
29   /**  Macros.
30   **/
31     /* Word axis macros.  For 31-bit axes only.
32     */
33       /* u3x_dep(): number of axis bits.
34       */
35 #       define u3x_dep(a_w)   (c3_bits_word(a_w) - 1)
36 
37       /* u3x_cap(): root axis, 2 or 3.
38       */
39 #       define u3x_cap(a_w)   (0x2 | (a_w >> (u3x_dep(a_w) - 1)))
40 
41       /* u3x_mas(): remainder after cap.
42       */
43 #       define u3x_mas(a_w) \
44           ( (a_w & ~(1 << u3x_dep(a_w))) | (1 << (u3x_dep(a_w) - 1)) )
45 
46       /* u3x_peg(): connect two axes.
47       */
48 #       define u3x_peg(a_w, b_w) \
49           ( (a_w << u3x_dep(b_w)) | (b_w &~ (1 << u3x_dep(b_w))) )
50 
51   /**  Functions.
52   **/
53     /** u3x_*: read, but bail with c3__exit on a crash.
54     **/
55 #if 1
56 #     define u3x_h(som)  u3a_h(som)
57 #     define u3x_t(som)  u3a_t(som)
58 #else
59       /* u3x_h (u3h): head.
60       */
61         u3_noun
62         u3x_h(u3_noun som);
63 
64       /* u3x_t (u3t): tail.
65       */
66         u3_noun
67         u3x_t(u3_noun som);
68 #endif
69       /* u3x_good(): test for u3_none.
70       */
71         u3_noun
72         u3x_good(u3_weak som);
73 
74       /* u3x_at (u3at): fragment.
75       */
76         u3_noun
77         u3x_at(u3_noun axe, u3_noun som);
78 
79       /* u3x_cell():
80       **
81       **   Divide `a` as a cell `[b c]`.
82       */
83         void
84         u3x_cell(u3_noun  a,
85                    u3_noun* b,
86                    u3_noun* c);
87 
88       /* u3x_trel():
89       **
90       **   Divide `a` as a trel `[b c d]`, or bail.
91       */
92         void
93         u3x_trel(u3_noun  a,
94                    u3_noun* b,
95                    u3_noun* c,
96                    u3_noun* d);
97 
98       /* u3x_qual():
99       **
100       **   Divide `a` as a quadruple `[b c d e]`.
101       */
102         void
103         u3x_qual(u3_noun  a,
104                    u3_noun* b,
105                    u3_noun* c,
106                    u3_noun* d,
107                    u3_noun* e);
108 
109       /* u3x_quil():
110       **
111       **   Divide `a` as a quintuple `[b c d e f]`.
112       */
113         void
114         u3x_quil(u3_noun  a,
115                    u3_noun* b,
116                    u3_noun* c,
117                    u3_noun* d,
118                    u3_noun* e,
119                    u3_noun* f);
120 
121       /* u3x_hext():
122       **
123       **   Divide `a` as a hextuple `[b c d e f g]`.
124       */
125         void
126         u3x_hext(u3_noun  a,
127                    u3_noun* b,
128                    u3_noun* c,
129                    u3_noun* d,
130                    u3_noun* e,
131                    u3_noun* f,
132                    u3_noun* g);
133