aboutsummaryrefslogtreecommitdiff
path: root/bf.lang
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-08-26 23:16:00 +0200
committertomsmeding <tom.smeding@gmail.com>2017-08-26 23:16:15 +0200
commitaa049227c17f15ad22092f1fcab4410bbf3521ba (patch)
tree7046e62ff530746754e19d07d4e8bc7d7a42ea22 /bf.lang
parentb2c5ef755bc7a2c736c5f52c4753dde66c04c3aa (diff)
Cleanup and features
debugger, bitwise ops, bounds checking, hex literals, better typing of some optimisations, makefile fix, exit function.
Diffstat (limited to 'bf.lang')
-rw-r--r--bf.lang14
1 files changed, 10 insertions, 4 deletions
diff --git a/bf.lang b/bf.lang
index e2f6788..6f7426b 100644
--- a/bf.lang
+++ b/bf.lang
@@ -22,7 +22,7 @@ func int[] makejumpmap(char[] src, int srclen) {
int stkp := 0;
int i := 0;
while (i < srclen) {
- putint(i); putc(' '); putint(stkp); putc(' '); putc(src[i]); putc('\n');
+ // putint(i); putc(' '); putint(stkp); putc(' '); putc(src[i]); putc('\n');
if (src[i] == '[') {
stack[stkp] = i;
stkp = stkp + 1;
@@ -35,6 +35,9 @@ func int[] makejumpmap(char[] src, int srclen) {
}
i = i + 1;
}
+ if (stkp != 0) {
+ exit(1);
+ }
/*i = 0;
while (i < srclen) {
putint(jm[i]);
@@ -72,17 +75,20 @@ func interpret(char[] src, int srclen) {
ip = ip + 1;
}
+ // debugger;
+
+ putc('\n');
memp = 0;
while (memp < 10) {
- putint(int(mem[memp])); putc(' ');
+ putint(int(mem[memp]) & 0xff); putc(' ');
memp = memp + 1;
}
putc('\n');
}
func int main() {
- int bufsize := 4088;
- char[] source := new char[4088];
+ int bufsize := 12280;
+ char[] source := new char[12280];
int sourcelen := 0;
while (1) {