From 5b29fe618017a9012b4d1ee5c10bc5c7d5b6708b Mon Sep 17 00:00:00 2001 From: ChinYikMing Date: Sun, 17 Sep 2023 21:05:43 +0800 Subject: [PATCH] Tweak memory allocation size for portability Close #161 --- src/io.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/io.c b/src/io.c index ad78c50f..98182fe7 100644 --- a/src/io.c +++ b/src/io.c @@ -17,8 +17,17 @@ #include "io.h" static uint8_t *data_memory_base; -/* set memory size to 2^32 bytes */ -#define MEM_SIZE 0x100000000ULL + +/* + * set memory size to 2^32 - 1 bytes + * + * The memory size is set to 2^32 - 1 bytes in order + * to make rv32emu portable for both 32-bit and 64-bit platforms. + * As a result, rv32emu can access any segment of the memory in + * either platform. Furthermore, it is safe because most of the  + * test cases' data memory usage will not exceed this memory size. + */ +#define MEM_SIZE 0xFFFFFFFFULL memory_t *memory_new() {