From af713b78e1f9227f4e39261d330d87dccc2ce42e Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Thu, 22 Jan 2015 21:58:56 -0500 Subject: [PATCH] Fix off-by-one in reading cache address from memory Commit a9ac7c153 properly avoided writing past the end of cache_line, but in doing so introduced an error as to the first memory address that should be written. This fix avoids writing past the cache_line by simply reading the previous memory location. Fixes the CP/M 68K simulation example and issue #181 --- SAGE/m68k_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SAGE/m68k_cpu.c b/SAGE/m68k_cpu.c index 3cb8c906..30a18152 100644 --- a/SAGE/m68k_cpu.c +++ b/SAGE/m68k_cpu.c @@ -269,7 +269,7 @@ static t_stat ReadICache(t_addr tpc) t_stat rc; uint8* mem; - ASSERT_OKRET(Mem((tpc+CACHE_SIZE)&addrmask,&mem)); + ASSERT_OKRET(Mem((tpc+CACHE_SIZE-1)&addrmask,&mem)); /* 68000/08/10 do not like unaligned access */ if (cputype < 3 && (tpc & 1)) return STOP_ERRADR;