Add commander x16 as target machine

This commit is contained in:
drmortalwombat 2023-03-24 21:06:27 +01:00
parent c2c0244990
commit 36a57c87d8
5 changed files with 41 additions and 2 deletions

View File

@ -110,6 +110,7 @@ A list of source files can be provided.
* nes_mmc1 : Nintendo entertainment system, MMC1, 256K PROM, 128K CROM
* nes_mmc3 : Nintendo entertainment system, MMC3, 512K PROM, 256K CROM
* atari : Atari 8bit systems, (0x2000..0xbc00)
* x16 : Commander X16, (0x0800..0x9f00)
### Files generated

View File

@ -35,7 +35,13 @@ loop:
sty accu + 2
lda #0
sta accu + 3
#elif defined(__X16__)
jsr $ffde
sta accu + 0
stx accu + 1
sty accu + 2
lda #0
sta accu + 3
#else
lda $a2
sta accu + 0

View File

@ -67,6 +67,22 @@ bool Compiler::ParseSource(void)
BC_REG_TMP = 0xa5;
BC_REG_TMP_SAVED = 0xc5;
}
else if (mTargetMachine == TMACH_X16)
{
BC_REG_WORK_Y = 0x22;
BC_REG_WORK = 0x23;
BC_REG_FPARAMS = 0x2d;
BC_REG_FPARAMS_END = 0x39;
BC_REG_IP = 0x39;
BC_REG_ACCU = 0x3b;
BC_REG_ADDR = 0x3f;
BC_REG_STACK = 0x43;
BC_REG_LOCALS = 0x45;
BC_REG_TMP = 0x47;
BC_REG_TMP_SAVED = 0x67;
}
else if (mCompilerOptions & COPT_EXTENDED_ZERO_PAGE)
{
BC_REG_FPARAMS = 0x0d;
@ -95,6 +111,7 @@ bool Compiler::ParseSource(void)
case TMACH_PET_16K:
case TMACH_VIC20_16K:
case TMACH_VIC20_24K:
case TMACH_X16:
mCompilationUnits->mSectionStack->mSize = 1024;
mCompilationUnits->mSectionHeap->mSize = 1024;
break;
@ -248,6 +265,7 @@ bool Compiler::GenerateCode(void)
switch (mTargetMachine)
{
case TMACH_C64:
case TMACH_X16:
if (mCompilerOptions & COPT_NATIVE)
regionStartup = mLinker->AddRegion(identStartup, 0x0801, 0x0880);
else
@ -343,6 +361,7 @@ bool Compiler::GenerateCode(void)
switch (mTargetMachine)
{
case TMACH_C64:
case TMACH_X16:
regionBytecode = mLinker->AddRegion(identBytecode, 0x0900, 0x0a00);
break;
case TMACH_C128:
@ -402,6 +421,9 @@ bool Compiler::GenerateCode(void)
case TMACH_C64:
regionMain = mLinker->AddRegion(identMain, 0x0a00, 0xa000);
break;
case TMACH_X16:
regionMain = mLinker->AddRegion(identMain, 0x0a00, 0x9f00);
break;
case TMACH_C128:
regionMain = mLinker->AddRegion(identMain, 0x1e00, 0xfe00);
break;
@ -447,6 +469,9 @@ bool Compiler::GenerateCode(void)
case TMACH_C64:
regionMain = mLinker->AddRegion(identMain, 0x0880, 0xa000);
break;
case TMACH_X16:
regionMain = mLinker->AddRegion(identMain, 0x0880, 0x9f00);
break;
case TMACH_C128:
regionMain = mLinker->AddRegion(identMain, 0x1d00, 0xfe00);
break;

View File

@ -58,7 +58,8 @@ enum TargetMachine
TMACH_NES_NROM_V,
TMACH_NES_MMC1,
TMACH_NES_MMC3,
TMACH_ATARI
TMACH_ATARI,
TMACH_X16
};

View File

@ -308,6 +308,12 @@ int main2(int argc, const char** argv)
compiler->mTargetMachine = TMACH_PLUS4;
compiler->AddDefine(Ident::Unique("__PLUS4__"), "1");
}
else if (!strcmp(targetMachine, "x16"))
{
strcpy_s(basicStart, "0x0801");
compiler->mTargetMachine = TMACH_X16;
compiler->AddDefine(Ident::Unique("__X16__"), "1");
}
else if (!strcmp(targetMachine, "nes"))
{
compiler->mTargetMachine = TMACH_NES;