aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-07-09 15:43:10 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-07-09 15:43:10 +0300
commit7f1f9ec8e75b3627b795ddecd7e391a5ebe95528 (patch)
tree88efbff4d9d64f6589687a59224d245e00975d0d /example
parent2432cb953afa8ec3063307e3a788d7126b97318b (diff)
downloadbcgen-7f1f9ec8e75b3627b795ddecd7e391a5ebe95528.tar.gz
bcgen-7f1f9ec8e75b3627b795ddecd7e391a5ebe95528.zip
change so that bcode.h and bcode.c are generated
Diffstat (limited to 'example')
-rw-r--r--example/Makefile8
-rw-r--r--example/main.c6
-rw-r--r--example/rules.py3
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()