Rename macros for maximum memory sizes
authorHugo Villeneuve <hugo@hugovil.com>
Mon, 28 Oct 2013 02:28:03 +0000 (22:28 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Wed, 6 Nov 2013 02:50:18 +0000 (21:50 -0500)
src/memory.c
src/memory.h
src/options.c

index 402e73c..c748cfe 100644 (file)
 #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;
                }
index faaba95..d5e426d 100644 (file)
 
 #include <sys/types.h>
 
-#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 {
index 7b6143d..3616f51 100644 (file)
@@ -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. */