From dd2261ab6cd2b8ddc9fd0078c995ec943fee8dbd Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sun, 27 Oct 2013 22:28:03 -0400 Subject: [PATCH] Rename macros for maximum memory sizes --- src/memory.c | 30 +++++++++++++++--------------- src/memory.h | 13 +++++++++---- src/options.c | 6 +++--- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/memory.c b/src/memory.c index 402e73c..c748cfe 100644 --- a/src/memory.c +++ b/src/memory.c @@ -27,33 +27,33 @@ #include "hexfile.h" #include "memory.h" -static u_int8_t pgm_mem[PGM_MEM_SIZE]; -static u_int8_t int_mem[INT_MEM_SIZE]; -static u_int8_t ext_mem[EXT_MEM_SIZE]; +static u_int8_t pgm_mem[PGM_MEM_MAX_SIZE]; +static u_int8_t int_mem[INT_MEM_MAX_SIZE]; +static u_int8_t ext_mem[EXT_MEM_MAX_SIZE]; void memory_write8(int memory_id, unsigned long address, u_int8_t value) { switch (memory_id) { case PGM_MEM_ID: - if (address >= PGM_MEM_SIZE) { - printf("Address (%lu) is greater than PGM_MEM_SIZE\n", + if (address >= PGM_MEM_MAX_SIZE) { + printf("Address (%lu) is greater than PGM_MEM_MAX_SIZE\n", address); return; } else pgm_mem[address] = value; break; case INT_MEM_ID: - if (address >= INT_MEM_SIZE) { - printf("Address (%lu) is greater than INT_MEM_SIZE\n", + if (address >= INT_MEM_MAX_SIZE) { + printf("Address (%lu) is greater than INT_MEM_MAX_SIZE\n", address); return; } else int_mem[address] = value; break; case EXT_MEM_ID: - if (address >= EXT_MEM_SIZE) { - printf("Address (%lu) is greater than EXT_MEM_SIZE\n", + if (address >= EXT_MEM_MAX_SIZE) { + printf("Address (%lu) is greater than EXT_MEM_MAX_SIZE\n", address); return; } else @@ -70,28 +70,28 @@ memory_read8(int memory_id, unsigned long address) { switch (memory_id) { case PGM_MEM_ID: - if (address < PGM_MEM_SIZE) + if (address < PGM_MEM_MAX_SIZE) return pgm_mem[address]; else { - printf("Address (%lu) is greater than PGM_MEM_SIZE\n", + printf("Address (%lu) is greater than PGM_MEM_MAX_SIZE\n", address); return 0; } break; case INT_MEM_ID: - if (address < INT_MEM_SIZE) + if (address < INT_MEM_MAX_SIZE) return int_mem[address]; else { - printf("Address (%lu) is greater than INT_MEM_SIZE\n", + printf("Address (%lu) is greater than INT_MEM_MAX_SIZE\n", address); return 0; } break; case EXT_MEM_ID: - if (address < EXT_MEM_SIZE) + if (address < EXT_MEM_MAX_SIZE) return ext_mem[address]; else { - printf("Address (%lu) is greater than EXT_MEM_SIZE\n", + printf("Address (%lu) is greater than EXT_MEM_MAX_SIZE\n", address); return 0; } diff --git a/src/memory.h b/src/memory.h index faaba95..d5e426d 100644 --- a/src/memory.h +++ b/src/memory.h @@ -24,10 +24,15 @@ #include -#define PGM_MEM_SIZE 65536 -#define INT_MEM_SIZE 256 /* IRAM = Direct addresses $00 to $7F - * SFR = Direct addresses $80 to $FF */ -#define EXT_MEM_SIZE 65536 +#define PGM_MEM_MAX_SIZE 65536 +/* + * Direct addressing $00 to $7F = IRAM (8051) + * Direct addressing $80 to $FF = SFR (8051) + * Indirect addressing $80 to $FF = IRAM (8052) + */ +#define INT_MEM_MAX_SIZE 256 +#define EXT_MEM_MAX_SIZE 65536 + #define EXT_MEM_DEFAULT_SIZE 1024 enum { diff --git a/src/options.c b/src/options.c index 7b6143d..3616f51 100644 --- a/src/options.c +++ b/src/options.c @@ -87,10 +87,10 @@ decode_memory_size(char *arg, struct argp_state *state, int memid) int *dest; if (memid == INT_MEM_ID) { - max_size = INT_MEM_SIZE; + max_size = INT_MEM_MAX_SIZE; dest = &options.iram_size; } else { - max_size = EXT_MEM_SIZE; + max_size = EXT_MEM_MAX_SIZE; dest = &options.xram_size; } @@ -155,7 +155,7 @@ parse_command_line_options(int argc, char *argv[]) /* Setting default values. */ options.filename = NULL; - options.iram_size = INT_MEM_SIZE; + options.iram_size = INT_MEM_MAX_SIZE; options.xram_size = EXT_MEM_DEFAULT_SIZE; /* Parse our arguments. */ -- 2.20.1