repos / gbc

GBC - Go B Compiler
git clone https://github.com/xplshn/gbc.git

gbc / tests
xplshn  ·  2025-08-13

vector.b

B
 1test1() {
 2    extrn printf;
 3    auto xs 4, W;
 4    W = &0[1]; // word size
 5
 6    *xs = 34;
 7    *(xs + 1*W) = '+';
 8    xs[2] = 35;
 9    xs[3] = 69;
10
11    printf(
12        "%d %c %d = %d\n",
13        xs[0],
14        xs[1],
15        *(xs + 2*W),
16        *(xs + 3*W)
17    );
18}
19
20COUNT 3;
21A "Just";
22B "Testing";
23C "Globals";
24LIST A, B, C;
25test2() {
26    extrn printf;
27    auto i; i = 0;
28    while (i < COUNT) printf("%s\n", *((&LIST)[i++]) );
29}
30
31N  5 ;
32V [5];
33test3() {
34    extrn printf;
35    auto i;
36    i = 0; while (i < N) V[i] = ++i * 2;
37    i = 0; while (i < N) printf("%d => %d\n", i, V[i++]);
38}
39
40
41main() {
42    test1();
43    test2();
44    test3();
45}