diff options
author | Rasmus Luha <rasmus.luha@gmail.com> | 2022-11-03 01:08:28 +0200 |
---|---|---|
committer | Rasmus Luha <rasmus.luha@gmail.com> | 2022-11-03 01:08:28 +0200 |
commit | 4bdad2d5c7dec0eb19c418cadb47cc3124092310 (patch) | |
tree | c80d9cceb8e10e91daf38657cf64d8ce0bbf3104 /src/mem.c | |
parent | fcb9ff2b96de6989e9a676e96753b1b1279acf67 (diff) |
Diffstat (limited to 'src/mem.c')
-rw-r--r-- | src/mem.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -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; + //} +} + +*/ |