mirror of
https://github.com/pnx/m16vm
synced 2026-06-16 03:44:55 +02:00
mm: change variable name from "memory" to "mm_base_addr"
This commit is contained in:
parent
e92b7ee551
commit
76a72e6857
3 changed files with 9 additions and 9 deletions
14
vm/mm.c
14
vm/mm.c
|
|
@ -27,13 +27,13 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get a WORD aligned (16-bit) address.
|
// Get a WORD aligned (16-bit) address.
|
||||||
// Casts the 8-bit pointer (memory) to 16-bit (WORD) and add offset.
|
// Casts the 8-bit pointer (mm_base_addr) to 16-bit (WORD) and add offset.
|
||||||
#define addr_align_word(offset) \
|
#define addr_align_word(offset) \
|
||||||
(((uint16_t*) memory) + (offset))
|
(((uint16_t*) mm_base_addr) + (offset))
|
||||||
|
|
||||||
#define EXCEPTION_STRING "Runtime exception: Memory address '%u' is out of bounds.\n"
|
#define EXCEPTION_STRING "Runtime exception: Memory address '%u' is out of bounds.\n"
|
||||||
|
|
||||||
uint8_t *memory = NULL;
|
uint8_t *mm_base_addr = NULL;
|
||||||
|
|
||||||
#define __check_bounds(addr) \
|
#define __check_bounds(addr) \
|
||||||
if ((addr) + 1 > MEM_SIZE) { \
|
if ((addr) + 1 > MEM_SIZE) { \
|
||||||
|
|
@ -43,14 +43,14 @@ uint8_t *memory = NULL;
|
||||||
|
|
||||||
void mm_init() {
|
void mm_init() {
|
||||||
|
|
||||||
memory = (uint8_t*) malloc(MEM_SIZE);
|
mm_base_addr = (uint8_t*) malloc(MEM_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mm_exit() {
|
void mm_exit() {
|
||||||
|
|
||||||
if (memory) {
|
if (mm_base_addr) {
|
||||||
free(memory);
|
free(mm_base_addr);
|
||||||
memory = NULL;
|
mm_base_addr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
vm/mm.h
2
vm/mm.h
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern uint8_t *memory;
|
extern uint8_t *mm_base_addr;
|
||||||
|
|
||||||
void mm_init();
|
void mm_init();
|
||||||
|
|
||||||
|
|
|
||||||
2
vm/vm.c
2
vm/vm.c
|
|
@ -45,7 +45,7 @@ void run(struct program *prog) {
|
||||||
debug_print_regs(state.reg);
|
debug_print_regs(state.reg);
|
||||||
|
|
||||||
if (debug_mem)
|
if (debug_mem)
|
||||||
debug_print_memory(memory);
|
debug_print_memory(mm_base_addr);
|
||||||
|
|
||||||
mm_exit();
|
mm_exit();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue