Eprom emulation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
|
||||
from h8536.emulator import H8536Emulator
|
||||
from h8536.emulator import H8536Emulator, MemoryMap, P7DDR, P7DR
|
||||
|
||||
|
||||
def rom_with_reset(*, reset: int = 0x1000, size: int = 0x1100) -> bytearray:
|
||||
@@ -10,6 +10,35 @@ def rom_with_reset(*, reset: int = 0x1000, size: int = 0x1100) -> bytearray:
|
||||
|
||||
|
||||
class EmulatorAddressingTest(unittest.TestCase):
|
||||
def test_p7dr_reads_external_pin_state_for_input_bits(self):
|
||||
memory = MemoryMap(b"\x00" * 4, p7_input=0xFF)
|
||||
|
||||
memory.write8(P7DDR, 0x00)
|
||||
memory.write8(P7DR, 0x00)
|
||||
|
||||
self.assertEqual(memory.read8(P7DR), 0xFF)
|
||||
|
||||
def test_p7dr_output_bits_read_latch_while_input_bits_read_pins(self):
|
||||
memory = MemoryMap(b"\x00" * 4, p7_input=0x7F)
|
||||
|
||||
memory.write8(P7DDR, 0x80)
|
||||
memory.write8(P7DR, 0x00)
|
||||
|
||||
self.assertEqual(memory.read8(P7DR), 0x7F)
|
||||
|
||||
def test_factory_eeprom_seed_populates_shadow_and_page_labels(self):
|
||||
rom = bytearray([0xFF] * 0xCB00)
|
||||
rom[0xC966:0xC968] = b"\x6B\x6F"
|
||||
rom[0xC974:0xC976] = b"\x80\x00"
|
||||
|
||||
memory = MemoryMap(bytes(rom))
|
||||
memory.seed_factory_eeprom_and_shadow()
|
||||
|
||||
self.assertEqual(memory.read16(0xF402), 0x6B6F)
|
||||
self.assertEqual(memory.p9_bus.fast_read_word(0x0010), (True, 0x8000))
|
||||
self.assertEqual(memory.p9_bus.fast_read_word(0x0110), (True, 0x8000))
|
||||
self.assertEqual(memory.p9_bus.fast_read_word(0x0002), (True, 0x2020))
|
||||
|
||||
def test_txi_indexed_byte_load_uses_signed_word_displacement_and_full_index_register(self):
|
||||
rom = rom_with_reset()
|
||||
rom[0x1000:0x1004] = b"\xF0\xF8\x58\x80" # MOV:G.B @(-H'07A8,R0), R0
|
||||
@@ -62,7 +91,7 @@ class EmulatorAddressingTest(unittest.TestCase):
|
||||
rom = rom_with_reset()
|
||||
rom[0x1000:0x1003] = b"\xE1\xFE\x81" # MOV:G.B @(H'-02,R1), R1
|
||||
|
||||
emulator = H8536Emulator(bytes(rom))
|
||||
emulator = H8536Emulator(bytes(rom), p7_input=0x37)
|
||||
emulator.cpu.regs[1] = 0xFE90
|
||||
emulator.memory.write8(0xFE8E, 0x37)
|
||||
emulator.step()
|
||||
|
||||
Reference in New Issue
Block a user