From fcb9ff2b96de6989e9a676e96753b1b1279acf67 Mon Sep 17 00:00:00 2001 From: Rasmus Luha Date: Sat, 22 Oct 2022 02:45:34 +0300 Subject: hw3 status --- src/mem.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/mem.c') 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 #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"); } -- cgit v1.2.3