From b6d6ec716f421853c280a7d1b7c7e49cea78faea Mon Sep 17 00:00:00 2001 From: ChinYikMing Date: Sun, 17 Sep 2023 18:48:02 +0800 Subject: [PATCH] Tweak memory allocation size for portability Close #161 --- src/io.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/io.c b/src/io.c index ad78c50f3..b6e68649b 100644 --- a/src/io.c +++ b/src/io.c @@ -17,8 +17,15 @@ #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 + * + * In order to make rv32emu portable for both 32-bit and 64-bit systems, + * we need keep the memory size to a maximum of 2^32 - 1 bytes, + * this allows rv32emu to access every segment of memory in either environment. + * Furthermore, it is safe since most test cases' data memory usage + * will not exceed 0xFFFFFFFF for now. + */ +#define MEM_SIZE 0xFFFFFFFFULL memory_t *memory_new() {