1
0
Fork 0
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:
Henrik Hautakoski 2019-04-26 13:30:26 +02:00
parent e92b7ee551
commit 76a72e6857
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA
3 changed files with 9 additions and 9 deletions

14
vm/mm.c
View file

@ -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;
} }
} }

View file

@ -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();

View file

@ -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();
} }