From d0cee0f6b6b19fab09b425f2db579bad792b2744 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sat, 1 Feb 2014 08:12:19 -0800 Subject: [PATCH] SWTP: Fixes to segfault issue described in #103 (from Gene Irwin) The simulated memory address block from 0x8000 thru 0x8FFF is defined to have address 0x8000 - 0x801F mapped to I/O ports and 0x8020 - 0x8FFF as NO RAM ALLOWED. Code has been added to behave reasonably when references are made to 0x8020 - 0x8FFF. --- swtp6800/common/mp-b2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/swtp6800/common/mp-b2.c b/swtp6800/common/mp-b2.c index c5253ec9..bcab28bd 100644 --- a/swtp6800/common/mp-b2.c +++ b/swtp6800/common/mp-b2.c @@ -214,7 +214,10 @@ int32 MB_get_mbyte(int32 addr) } else return 0xFF; case 0x8000: - val = (dev_table[addr - 0x8000].routine(0, 0)) & 0xFF; + if (addr < 0x8020) + val = (dev_table[addr - 0x8000].routine(0, 0)) & 0xFF; + else + val = 0xFF; if (MB_dev.dctrl & DEBUG_read) printf("MB_get_mbyte: I/O addr=%04X val=%02X\n", addr, val); return val; @@ -290,7 +293,8 @@ void MB_put_mbyte(int32 addr, int32 val) return; } case 0x8000: - dev_table[addr - 0x8000].routine(1, val); + if (addr < 0x8020) + dev_table[addr - 0x8000].routine(1, val); return; case 0xA000: case 0xB000: @@ -320,3 +324,4 @@ void MB_put_mword(int32 addr, int32 val) } /* end of mp-b2.c */ +