summaryrefslogtreecommitdiff
path: root/src/mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem.c')
-rw-r--r--src/mem.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/mem.c b/src/mem.c
index 798fa1b..9b43c9d 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <string.h>
#include "mem.h"
struct mem_st mem = { .pos = 0, .arr={0}};
@@ -62,3 +63,37 @@ void mem_printDebug(){
}
printf("\n");
}
+
+
+
+/*
+// Praks 10-11 Added
+
+void mem_add(int amount){
+ mem.arr[mem.pos] += amount;
+}
+
+mem_int(){return mem_add(-1);};
+mem_dec(){return mem_add(1);};
+
+int mem_move(int amount) {
+ int new_pos = mem.pos + amount;
+ if (amount < 0) {
+ //NB, siin võib olla probleem
+ new_pos += (MEM_SIZE -1);
+ }
+ else if (new_pos >= MEM_SIZE){
+ new_pos %= MEM_SIZE;
+ }
+ mem.pos = new_pos;
+ return mem_pos;
+}
+
+void mem_init() {
+ memset(mem.arr, 0, MEM_SIZE * sizeof(char));
+ //for (int i = 0; i < MEM_SIZE; ++i) {
+ // mem.arr[i] = 0;
+ //}
+}
+
+*/