repos / gbc

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

gbc / examples
xplshn  ·  2025-08-13

seq.b

B
 1// -*- mode: simpc -*-
 2
 3// TODO: doesn't work on gas-x86_64-windows target due to linking error when using stderr
 4main(argc, argv) {
 5    extrn printf, fprintf, stderr, atoi;
 6
 7    if (argc <= 1) {
 8        fprintf(stderr, "%s: missing operand\n", argv[0]);
 9        return(1);
10    }
11
12    auto i, n;
13    n = atoi(argv[1]);
14    i = 1;
15    while (i <= n) {
16        printf("%d\n", i);
17        i += 1;
18    }
19}