#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
{
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;
}
#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 {
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;
}
/* 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. */