Table of Contents Previous topic Next topic
Extension Examples->Memory Bank Switching->Introduction
This example demonstrates a method of switching xdata memory banks. SetPortPins() is used to intercept writes to port 1. The settings of pins 0 and 1 indicate which memory bank should be active.
The extension looks after memory banks 1, 2 and 3. The simulator looks after memory bank 0.
Whenever memory banks 1, 2 or 3 are active and the xdata address falls within the banked memory range, GetXDataMemory() returns the memory contents and SetXDataMemory() stores the memory contents.
A similar approach, using GetProgramMemory() and SetProgramMemory(), could be used to switch program memory banks.
This example does not support the capture state feature and so if a simulator state is captured and later restored, the contents of memory banks 1, 2 and 3 will not be restored.
This example does not make use of the nExtensionState parameter but it must nevertheless return a not zero value in response to the Initialise() call.