Move macro definition to top of file
[emu8051.git] / src / common / memory.c
index c5b2acf..2e37210 100644 (file)
@@ -75,6 +75,12 @@ memory_init(void)
        }
 }
 
+u_int8_t *
+memory_getbuf(enum mem_id_t id, unsigned long address)
+{
+       return &mem_infos[id].buf[address];
+}
+
 void
 memory_clear(enum mem_id_t id)
 {
@@ -84,10 +90,10 @@ memory_clear(enum mem_id_t id)
 void
 memory_write8(enum mem_id_t id, unsigned long address, u_int8_t value)
 {
-       if (address >= mem_infos[id].max_size) {
-               printf("Error writing to memory ID: %d\n", id);
-               printf("  Address (%lu) greater than maximum memory size\n",
-                      address);
+       if (address >= (unsigned long) mem_infos[id].max_size) {
+               log_err("Error writing to memory ID: %d\n"
+                       "  Address (%lu) greater than maximum memory size",
+                       id, address);
                return;
        } else
                mem_infos[id].buf[address] = value;
@@ -110,10 +116,10 @@ memory_sfr_write_dptr(u_int16_t value)
 u_int8_t
 memory_read8(enum mem_id_t id, unsigned long address)
 {
-       if (address >= mem_infos[id].max_size) {
-               printf("Error reading from memory ID: %d\n", id);
-               printf("  Address (%lu) greater than maximum memory size\n",
-                      address);
+       if (address >= (unsigned long) mem_infos[id].max_size) {
+               log_err("Error reading from memory ID: %d\n"
+                       "  Address (%lu) greater than maximum memory size",
+                       id, address);
                return 0;
        } else
                return mem_infos[id].buf[address];