repos / gbc

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

gbc / tests
xplshn  ·  2025-08-13

divmod.b

B
 1div(a, b) {
 2    extrn printf;
 3    printf("%d/%d = %d\n", a, b, a/b);
 4}
 5
 6mod(a, b) {
 7    extrn printf;
 8    printf("%d%%%d = %d\n", a, b, a%b);
 9}
10
11main() {
12    extrn printf;
13    printf("Division:\n");
14    div(   1, 100);
15    div(  -1, 100);
16    div( 100, 100);
17    div(-100, 100);
18    div( 101, 100);
19    div(-101, 100);
20    div( 201, 100);
21    div(-201, 100);
22    printf("\n");
23    printf("Remainder:\n");
24    mod(  1, 100);
25    mod( 99, 100);
26    mod(100, 100);
27    mod(101, 100);
28    mod(201, 100);
29    mod( -1, 100);
30}