diff --git a/src/vm_segment.c b/src/vm_segment.c index 93aa108..14d8b04 100644 --- a/src/vm_segment.c +++ b/src/vm_segment.c @@ -95,6 +95,12 @@ vm_segment_set(vm_segment *segment, size_t index, vm_8bit value) return ERR_OOB; } + // Check if we have a write mapper + if (segment->write_table[index]) { + segment->write_table[index](segment, index, value); + return OK; + } + segment->memory[index] = value; return OK; } @@ -117,6 +123,11 @@ vm_segment_get(vm_segment *segment, size_t index) exit(1); } + // We may have a read mapper for this address + if (segment->read_table[index]) { + return segment->read_table[index](segment, index); + } + return segment->memory[index]; }