umx

UMX VM implementation (ifcfc '06)
git clone git://bsandro.tech/umx
Log | Files | Refs

commit 78b6c121ea9a9e9106c677168677d4d1388adb03
parent 2f650974cc8ca7a4796d54513fd0ab2a5c870d2e
Author: bsandro <brian.drosan@gmail.com>
Date:   Tue, 11 Jan 2022 00:27:31 +0200

mem bugfixes

Diffstat:
Mmain.c | 15+++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/main.c b/main.c @@ -8,7 +8,7 @@ #include <unistd.h> #include <sys/stat.h> -#define FILENAME "sandmark.umz" +#define FILENAME "codex.umz" #define PLATTER_SIZE 4 struct array_t { @@ -64,7 +64,7 @@ int main(void) struct stat fileinfo; size_t read_platters = 0; - memset(state, 0, sizeof(struct arena_t)); + memset(state, 0, sizeof(struct state_t)); assert(f != NULL); stat(FILENAME, &fileinfo); @@ -89,11 +89,11 @@ int main(void) instruction.reg_b = (platter & 56) >> 3; // mask 000 111 000 = 56 instruction.reg_c = platter & 7; // mask 000 000 111 = 7 } - printf("[%2d][%8x]", state->finger, platter); - print_instruction(instruction); + //printf("[%2d][%8x]\n", state->finger, platter); + //print_instruction(instruction); state->finger++; - //exec_instruction(state, instruction); - sleep(1); + exec_instruction(state, instruction); + //sleep(1); } //getchar(); // in case SIOUX starts closing the window after exec again @@ -125,7 +125,7 @@ void exec_instruction(struct state_t *state, struct instruction_t in) { state->registers[in.reg_a] = state->arena.arrays[state->registers[in.reg_b]].data[state->registers[in.reg_c]]; break; case ARRA: - state->arena.arrays[in.reg_a].data[state->registers[in.reg_b]] = state->registers[in.reg_c]; + state->arena.arrays[state->registers[in.reg_a]].data[state->registers[in.reg_b]] = state->registers[in.reg_c]; break; case ADD: state->registers[in.reg_a] = state->registers[in.reg_b] + state->registers[in.reg_c]; //@todo: modulo 2^32 ? @@ -176,7 +176,6 @@ void exec_instruction(struct state_t *state, struct instruction_t in) { uint32_t array_new(struct arena_t *arena, uint32_t size) { uint32_t array_index = arena->size++; assert(arena != NULL); - assert(size != 0); arena->arrays = (struct array_t *)realloc(arena->arrays, arena->size * sizeof(struct array_t)); arena->arrays[array_index].data = (uint32_t *)calloc(size, PLATTER_SIZE); arena->arrays[array_index].size = size;