umx

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

commit 2f650974cc8ca7a4796d54513fd0ab2a5c870d2e
parent 6472a5ff315b33ad4253e5a329d499081b540469
Author: bsandro <brian.drosan@gmail.com>
Date:   Mon, 10 Jan 2022 23:32:13 +0200

still debugging

Diffstat:
Mmain.c | 24+++++++++++-------------
Mumx | 0
2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/main.c b/main.c @@ -60,28 +60,26 @@ void array_dup(struct arena_t *arena, uint32_t index); int main(void) { FILE *f = fopen(FILENAME, "r"); - struct state_t state = {0}; + struct state_t *state = (struct state_t *)malloc(sizeof(struct state_t)); struct stat fileinfo; size_t read_platters = 0; - state.finger = 0; - state.arena.arrays = NULL; - state.arena.size = 0; - + memset(state, 0, sizeof(struct arena_t)); + assert(f != NULL); stat(FILENAME, &fileinfo); assert(fileinfo.st_size % PLATTER_SIZE == 0); printf("%s (%lu bytes):\n", FILENAME, fileinfo.st_size); - array_new(&state.arena, fileinfo.st_size / PLATTER_SIZE); // Initial array #0 - read_platters = fread(state.arena.arrays[0].data, PLATTER_SIZE, fileinfo.st_size / PLATTER_SIZE, f); + array_new(&state->arena, fileinfo.st_size / PLATTER_SIZE); // Initial array #0 + read_platters = fread(state->arena.arrays[0].data, PLATTER_SIZE, fileinfo.st_size / PLATTER_SIZE, f); assert(fileinfo.st_size == read_platters * PLATTER_SIZE); - printf("read ok, %lu platters (%lu bytes)\n", read_platters, state.arena.arrays[0].size); + printf("read ok, %lu platters (%lu bytes)\n", read_platters, state->arena.arrays[0].size); fclose(f); while (1) { struct instruction_t instruction = {0}; - uint32_t platter = state.arena.arrays[0].data[state.finger]; - printf("[%s]", int2bin(platter)); + uint32_t platter = state->arena.arrays[0].data[state->finger]; + //printf("[%s]", int2bin(platter)); instruction.opcode = platter >> 28; if (instruction.opcode == ORTH) { instruction.reg_a = (platter >> 25) & 7; @@ -91,10 +89,10 @@ 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); + printf("[%2d][%8x]", state->finger, platter); print_instruction(instruction); - state.finger++; - exec_instruction(&state, instruction); + state->finger++; + //exec_instruction(state, instruction); sleep(1); } diff --git a/umx b/umx Binary files differ.