diff options
Diffstat (limited to 'example')
| -rw-r--r-- | example/Makefile | 8 | ||||
| -rw-r--r-- | example/main.c | 6 | ||||
| -rw-r--r-- | example/rules.py | 3 |
3 files changed, 9 insertions, 8 deletions
diff --git a/example/Makefile b/example/Makefile index 0bce1ec..d9b0158 100644 --- a/example/Makefile +++ b/example/Makefile @@ -5,13 +5,11 @@ all: exec exec: bcode.o main.o $(CC) $(CFLAGS) $^ -o $@ -bcode.o: ../bcode.c +bcode.o: bcode.c $(CC) $(CFLAGS) -c $^ -o $@ -../bcode.c: ../gen/select.h -../gen/select.h: rules.py - cd .. && ./bcgen example/rules.py - touch ../bcode.c # just to get make to wake up +bcode.c: rules.py + ../bcgen rules.py .PHONY: clean clean: diff --git a/example/main.c b/example/main.c index 7ca152b..7e086a7 100644 --- a/example/main.c +++ b/example/main.c @@ -1,5 +1,5 @@ #include <stdio.h> -#include "../bcode.h" +#include "bcode.h" int main() { @@ -10,10 +10,10 @@ int main() select_movi(&cs, 1, 1000000000); // limit select_movi(&cs, 0, 0); // total - breg_t l = label(&cs); // top + bcval_t l = label(&cs); // top select_addr(&cs, 0, 0, 2); // add iter to total select_addi(&cs, 2, 2, 1); - breloc_t r = select_bltr(&cs, 2, 1, 0); // 0 is placeholder value, + bcreloc_t r = select_bltr(&cs, 2, 1, 0); // 0 is placeholder value, // should maybe add in an // UNDEFINED macro or something end(&cs); diff --git a/example/rules.py b/example/rules.py index 9c8d62e..90d35b1 100644 --- a/example/rules.py +++ b/example/rules.py @@ -1,5 +1,8 @@ g = BCGen(r = 7, f = 0) + g.rule('addr', '_RRR__', 'R0 = R1 + R2;') g.rule('addi', '_RR__I', 'R0 = R1 + IMM;') g.rule('movi', '_R___I', 'R0 = IMM;') g.rule('bltr', 'rRR__I', 'if (R0 < R1) JUMP(IMM);') + +g.write() |
