summaryrefslogtreecommitdiff
path: root/src/mem.c
diff options
context:
space:
mode:
authorRasmus Luha <rasmus.luha@gmail.com>2022-10-22 02:45:34 +0300
committerRasmus Luha <rasmus.luha@gmail.com>2022-10-22 02:45:34 +0300
commitfcb9ff2b96de6989e9a676e96753b1b1279acf67 (patch)
treee9a8839939aac6eeba3dea89ca0c20ad8268150e /src/mem.c
parenta97b362e6a35be4575f7ded3c31cdeede89ab2a8 (diff)
hw3 status
Diffstat (limited to 'src/mem.c')
-rw-r--r--src/mem.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mem.c b/src/mem.c
index 3c605a5..798fa1b 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -1,7 +1,11 @@
#include <stdio.h>
#include "mem.h"
-struct mem_st mem = { .pos = 0};
+struct mem_st mem = { .pos = 0, .arr={0}};
+
+int mem_pos(){
+ return mem.pos;
+}
int mem_inc(){
mem.arr[mem.pos]++;
@@ -45,16 +49,16 @@ int mem_set(char v){
void mem_printDebug(){
if (mem.pos+9 >= MEM_SIZE)
- printf("index: %d [%d .. %d]: ", mem.pos, mem.pos, mem.pos-MEM_SIZE+9);
- printf("index: %d [%d .. %d]: ", mem.pos, mem.pos, mem.pos+9);
+ printf("index: %d mem [%d .. %d]:", mem.pos, mem.pos, mem.pos-MEM_SIZE+9);
+ printf("index: %d mem [%d .. %d]:", mem.pos, mem.pos, mem.pos+9);
for (int i = 0; i < 10; ++i) {
if (mem.pos+i >= MEM_SIZE) {
- printf("%d ", mem.arr[mem.pos-MEM_SIZE+i]);
+ printf("% d", mem.arr[mem.pos-MEM_SIZE+i]);
}
else {
- printf("%d ", mem.arr[mem.pos+i]);
+ printf("% d", mem.arr[mem.pos+i]);
}
}
-
+ printf("\n");
}