commit e3c58656dcb744bd6bf43e848028f4e2031ac11d
parent 1ca2c2fcdc0645612f90f8a0e6a152ab9ac110dc
Author: bsandro <brian.drosan@gmail.com>
Date: Mon, 10 Jan 2022 02:58:23 +0200
trying to debug ORTH (bugs out for now)
Diffstat:
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/main.c b/main.c
@@ -12,7 +12,7 @@
struct array_t {
uint32_t *data;
- size_t size;
+ uint32_t size;
};
struct arena_t {
@@ -21,9 +21,9 @@ struct arena_t {
};
struct state_t {
- struct arena_t arena;
uint32_t registers[8];
uint32_t finger;
+ struct arena_t arena;
};
enum opcode_t {
@@ -77,24 +77,21 @@ int main(void)
printf("read ok, %lu platters (%lu bytes)\n", read_platters, state.arena.arrays[0].size);
while (1) {
- uint32_t platter;
struct instruction_t instruction = {0};
- platter = state.arena.arrays[0].data[state.finger];
+ uint32_t platter = state.arena.arrays[0].data[state.finger];
instruction.opcode = platter >> 28;
if (instruction.opcode == ORTH) {
- instruction.reg_a = ((platter >> 25) & 7);
+ instruction.reg_a = (platter >> 25) & 7;
instruction.value = platter & 0x1FFFFFF;
} else {
instruction.reg_a = (platter & 448) >> 6; // mask 111 000 000 = 448
instruction.reg_b = (platter & 56) >> 3; // mask 000 111 000 = 56
instruction.reg_c = platter & 7; // mask 000 000 111 = 7
}
- //print_instruction(instruction);
+ printf("[%2d][%s][%x]", state.finger, int2bin(platter), platter);
+ print_instruction(instruction);
state.finger++;
exec_instruction(&state, instruction);
- if (state.finger >= state.arena.arrays[0].size / PLATTER_SIZE) {
- break;
- }
}
fclose(f);
@@ -190,12 +187,16 @@ void array_free(struct arena_t *arena, uint32_t index) {
assert(index < arena->size);
free(arena->arrays[index].data);
arena->arrays[index].size = 0;
+ //printf("freed array %lu\n", index);
}
void array_dup(struct arena_t *arena, uint32_t index) {
assert(index < arena->size);
array_free(arena, 0);
+ //printf("attempting malloc...\n");
arena->arrays[0].data = (uint32_t *)malloc(arena->arrays[index].size * PLATTER_SIZE);
+ //printf("attempting memcpy...\n");
memcpy(arena->arrays[0].data, arena->arrays[index].data, arena->arrays[index].size * PLATTER_SIZE);
arena->arrays[0].size = arena->arrays[index].size;
+ //printf("memcpy ok\n");
}
\ No newline at end of file
diff --git a/umx b/umx
Binary files differ.