CONTROL REGISTER

A tiny MMU for controlling the paged portion of RAM and the placement of the custom chip RAM, as well as an output LED and an input button. The computer offers a memory map which always begins with some unpaged SRAM (memory which is unaffected by the MMU). The stack should be placed at the end of this region. The interrupt vectors and initial program counter all reside at the beginning of this region. The portions of the main program, as well as bank-switching code, should/could also reside here. The size of this unpaged memory, is controlled by the S value in this register. Following the unpaged memory, is (possibly) a region of paged RAM, which will be discussed shortly. Following the paged RAM, is the custom chip RAM (Audio & Video). The content of these memory regions, depends upon the configuration of the specific chip. Following the custom chip memory, is (possibly) a region of paged RAM. Basically, the paged RAM shows through wherever there is not something else. The paged RAM can be manipulated using a variety of bits in this register, which can ultimately expose the entire 128K of SRAM through the available window. NOTE that you can (accidentally or intentionally) configure the MMU to mirror the unpaged memory to another region of the memory map. The unpaged memory always lies at the very beginning of SRAM.

u8 in IO at 0x00 called CONTROLREG

76543210
NBSSSLBB

B: RW [MMU] Selected Bank.0 (3 bits, select 0..7)
B: RW [MMU] Selected Bank.1
L: RW LED (1 = ON, 0 = OFF).
S: RW [MMU] Unpaged Memory Size (0..7 = 0x1000..0x8000.
B: RW [MMU] Selected Bank.2
N: R. Button (1 = released, 0 = pressed).

const SRAM_BANK_0


SRAM_BANK_0 = 0

const SRAM_BANK_1


SRAM_BANK_1 = 1

const SRAM_BANK_2


SRAM_BANK_2 = 2

const SRAM_BANK_3


SRAM_BANK_3 = 3

const SRAM_BANK_4


SRAM_BANK_4 = 64

const SRAM_BANK_5


SRAM_BANK_5 = 65

const SRAM_BANK_6


SRAM_BANK_6 = 66

const SRAM_BANK_7


SRAM_BANK_7 = 67

const LED_OFF


LED_OFF = 0

const LED_ON


LED_ON = 4

const LED_BIT


LED_BIT = 2

const LED_MASK


LED_MASK = 4

const SRAM_UNPAGED_SIZE_0K


SRAM_UNPAGED_SIZE_0K = 0

const SRAM_UNPAGED_SIZE_8K


SRAM_UNPAGED_SIZE_8K = 8

const SRAM_UNPAGED_SIZE_16K


SRAM_UNPAGED_SIZE_16K = 16

const SRAM_UNPAGED_SIZE_24K


SRAM_UNPAGED_SIZE_24K = 24

const SRAM_UNPAGED_SIZE_32K


SRAM_UNPAGED_SIZE_32K = 32

const SRAM_UNPAGED_SIZE_40K


SRAM_UNPAGED_SIZE_40K = 40

const SRAM_UNPAGED_SIZE_48K


SRAM_UNPAGED_SIZE_48K = 48

const SRAM_UNPAGED_SIZE_56K


SRAM_UNPAGED_SIZE_56K = 56

const BUTTON_MASK


BUTTON_MASK = 128

const BUTTON_BIT


BUTTON_BIT = 7

const BUTTON_DOWN


BUTTON_DOWN = 0

const BUTTON_UP


BUTTON_UP = 128