Skip to content

Handling banked ROM #6651

Answered by GhidorahRex
phaseseeker asked this question in Q&A
Jun 18, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

The easiest fix is to add a bank select context register value

define register offset=0x40 size=4 [ contextreg ];

define context contextreg
    bank=(0,0)
;

then specific constructors for BSET and BCLR for setting it:

:BCLR 0, DIRECT	is op4_7=1 & bit_0=1 & n=0; DIRECT & imm8=0x24
	[bank=0;]{
	local mask = ~1;
	DIRECT = DIRECT & mask;
}

:BSET 0, DIRECT	is op4_7=1 & bit_0=0 & n=0; DIRECT & imm8=0x24
	[bank=1;]{
	local mask = 1;
	DIRECT = DIRECT | mask;
}

You'll need to modify the addressing modes to account for the bit, as an example:

ADDR: addr 		is op4_6=3; imm8 [ addr=((bank << 14) | imm8);]	{ export *:1 addr; }
ADDR: addr 		is op4_6=4; imm16 [ addr=((bank << 14) | imm16);]		{ export…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@phaseseeker
Comment options

@phaseseeker
Comment options

Answer selected by phaseseeker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants