summaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/memory.c b/memory.c
index 75b041f..553766a 100644
--- a/memory.c
+++ b/memory.c
@@ -15,10 +15,26 @@
#include "nios2.h"
#include "memory.h"
-uint8_t memory_get_byte(struct memory *mem, int32_t offset)
+uint8_t memory_get_byte(struct memory *mem, int32_t addr)
{
uint8_t *base = (uint8_t *) mem->base;
- return base[offset];
+ return base[addr - mem->image_base];
+}
+
+void memory_set_byte(struct memory *mem, int32_t addr, uint8_t data)
+{
+ uint8_t *base = (uint8_t *) mem->base;
+ base[addr - mem->image_base] = data;
+}
+
+uint32_t memory_get_word(struct memory *mem, int32_t addr)
+{
+ return mem->base[(addr - mem->image_base) / 4];
+}
+
+void memory_set_word(struct memory *mem, int32_t addr, uint32_t data)
+{
+ mem->base[(addr - mem->image_base) / 4] = data;
}
void memory_dump(struct memory *mem, uint32_t offset, size_t count)