summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTyler Murphy <tylerm@tylerm.dev>2023-04-15 01:04:50 -0400
committerTyler Murphy <tylerm@tylerm.dev>2023-04-15 01:04:50 -0400
commit1b3c67ba06e3b41f308f9475968fe19f36b31f06 (patch)
treee7d32ca6dba3ab154a76f0c514ffed7a88a8baa3 /src
parenti made things faster (diff)
downloadbrainfucked-1b3c67ba06e3b41f308f9475968fe19f36b31f06.tar.gz
brainfucked-1b3c67ba06e3b41f308f9475968fe19f36b31f06.tar.bz2
brainfucked-1b3c67ba06e3b41f308f9475968fe19f36b31f06.zip
fix bug and add zero instruction
Diffstat (limited to '')
-rw-r--r--src/interpreter.c5
-rw-r--r--src/main.c1
-rw-r--r--src/program.c2
-rw-r--r--src/types.h1
4 files changed, 8 insertions, 1 deletions
diff --git a/src/interpreter.c b/src/interpreter.c
index 273d985..982108e 100644
--- a/src/interpreter.c
+++ b/src/interpreter.c
@@ -62,8 +62,8 @@ next:
break;
}
case EnterTape: {
- memcpy(&tape, tape_ptr(tape), sizeof(Tape*));
stack_push(&tape_stack, tape);
+ memcpy(&tape, tape_ptr(tape), sizeof(Tape*));
break;
}
case LeaveTape: {
@@ -82,6 +82,9 @@ next:
case Clear:
printf("\033c");
break;
+ case Zero:
+ memset(tape_ptr(tape), 0, tape_get(tape));
+ break;
case Eof:
goto end;
}
diff --git a/src/main.c b/src/main.c
index c51a88f..7032ca5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -20,6 +20,7 @@
/// ` Output null terminated string at current cell
/// ~ Input string into current cells with max length in current cell
/// % Clear screen
+/// $ Set n cells to 0 where n is the count of the current cell
int main(int argc, char** argv) {
diff --git a/src/program.c b/src/program.c
index 0fac9d5..c839461 100644
--- a/src/program.c
+++ b/src/program.c
@@ -48,6 +48,8 @@ retest:
return GetString;
case '%':
return Clear;
+ case '$':
+ return Zero;
case '\n':
case '\t':
case ' ':
diff --git a/src/types.h b/src/types.h
index 413d313..9241787 100644
--- a/src/types.h
+++ b/src/types.h
@@ -19,6 +19,7 @@ typedef enum {
PutString,
GetString,
Clear,
+ Zero,
Eof
} Symbol;