diff options
author | Rasmus Luha <rasmus.luha@gmail.com> | 2022-10-22 02:45:34 +0300 |
---|---|---|
committer | Rasmus Luha <rasmus.luha@gmail.com> | 2022-10-22 02:45:34 +0300 |
commit | fcb9ff2b96de6989e9a676e96753b1b1279acf67 (patch) | |
tree | e9a8839939aac6eeba3dea89ca0c20ad8268150e /src/mem.c | |
parent | a97b362e6a35be4575f7ded3c31cdeede89ab2a8 (diff) |
hw3 status
Diffstat (limited to 'src/mem.c')
-rw-r--r-- | src/mem.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -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"); } |