Start on 65816

This commit is contained in:
Lauri Kasanen
2022-10-12 11:03:57 +03:00
parent eede412959
commit 67384a29b7
7 changed files with 156 additions and 14 deletions

View File

@@ -194,6 +194,17 @@ unsigned long GetCodeDWord (unsigned Addr)
unsigned GetCodeLongAddr (unsigned Addr)
/* Get a word from the given address */
{
unsigned Lo = GetCodeByte (Addr);
unsigned Mid = GetCodeByte (Addr+1);
unsigned Hi = GetCodeByte (Addr+2);
return Lo | (Mid << 8) | (Hi << 16);
}
unsigned GetRemainingBytes (void)
/* Return the number of remaining code bytes */
{

View File

@@ -72,6 +72,9 @@ unsigned GetCodeWord (unsigned Addr);
unsigned long GetCodeDWord (unsigned Addr);
/* Get a dword from the given address */
unsigned GetCodeLongAddr (unsigned Addr);
/* Get a 24-bit address from the given address */
unsigned GetRemainingBytes (void);
/* Return the number of remaining code bytes */

View File

@@ -121,8 +121,10 @@ static const char* GetAddrArg (unsigned Flags, unsigned Addr)
static char Buf [32];
if (Addr < 0x100) {
xsprintf (Buf, sizeof (Buf), "$%02X", Addr);
} else {
} else if (Addr < 0x10000) {
xsprintf (Buf, sizeof (Buf), "$%04X", Addr);
} else {
xsprintf (Buf, sizeof (Buf), "$%06X", Addr);
}
return Buf;
}
@@ -322,14 +324,28 @@ void OH_AbsoluteY (const OpcDesc* D)
void OH_AbsoluteLong (const OpcDesc* D attribute ((unused)))
{
Error ("Not implemented");
/* Get the operand */
unsigned Addr = GetCodeLongAddr (PC+1);
/* Generate a label in pass 1 */
GenerateLabel (D->Flags, Addr);
/* Output the line */
OneLine (D, "%s%s", GetAbsOverride (D->Flags, Addr), GetAddrArg (D->Flags, Addr));
}
void OH_AbsoluteLongX (const OpcDesc* D attribute ((unused)))
{
Error ("Not implemented");
/* Get the operand */
unsigned Addr = GetCodeLongAddr (PC+1);
/* Generate a label in pass 1 */
GenerateLabel (D->Flags, Addr);
/* Output the line */
OneLine (D, "%s%s,x", GetAbsOverride (D->Flags, Addr), GetAddrArg (D->Flags, Addr));
}
@@ -358,7 +374,17 @@ void OH_Relative (const OpcDesc* D)
void OH_RelativeLong (const OpcDesc* D attribute ((unused)))
{
Error ("Not implemented");
/* Get the operand */
signed short Offs = GetCodeWord (PC+1);
/* Calculate the target address */
unsigned Addr = (((int) PC+3) + Offs) & 0xFFFF;
/* Generate a label in pass 1 */
GenerateLabel (D->Flags, Addr);
/* Output the line */
OneLine (D, "%s", GetAddrArg (D->Flags, Addr));
}
@@ -541,14 +567,15 @@ void OH_ImmediateAbsoluteX (const OpcDesc* D)
void OH_StackRelative (const OpcDesc* D attribute ((unused)))
{
Error ("Not implemented");
/* Output the line */
OneLine (D, "$%02X,s", GetCodeByte (PC+1));
}
void OH_DirectIndirectLongX (const OpcDesc* D attribute ((unused)))
{
Error ("Not implemented");
Error ("Not implemented %s", __FUNCTION__);
}
@@ -571,14 +598,28 @@ void OH_StackRelativeIndirectY4510 (const OpcDesc* D attribute ((unused)))
void OH_DirectIndirectLong (const OpcDesc* D attribute ((unused)))
{
Error ("Not implemented");
/* Get the operand */
unsigned Addr = GetCodeByte (PC+1);
/* Generate a label in pass 1 */
GenerateLabel (D->Flags, Addr);
/* Output the line */
OneLine (D, "[%s]", GetAddrArg (D->Flags, Addr));
}
void OH_DirectIndirectLongY (const OpcDesc* D attribute ((unused)))
{
Error ("Not implemented");
/* Get the operand */
unsigned Addr = GetCodeByte (PC+1);
/* Generate a label in pass 1 */
GenerateLabel (D->Flags, Addr);
/* Output the line */
OneLine (D, "[%s],y", GetAddrArg (D->Flags, Addr));
}

View File

@@ -427,8 +427,13 @@ static void OneOpcode (unsigned RemainingBytes)
switch (Style) {
case atDefault:
D->Handler (D);
PC += D->Size;
if (CPU == CPU_65816) {
DataByteLine (1);
++PC;
} else {
D->Handler (D);
PC += D->Size;
}
break;
case atCode:

View File

@@ -74,6 +74,7 @@ void SetOpcTable (cpu_t CPU)
case CPU_6502DTV: OpcTable = OpcTable_6502DTV; break;
case CPU_65SC02: OpcTable = OpcTable_65SC02; break;
case CPU_65C02: OpcTable = OpcTable_65C02; break;
case CPU_65816: OpcTable = OpcTable_65816; break;
case CPU_HUC6280: OpcTable = OpcTable_HuC6280; break;
case CPU_M740: OpcTable = OpcTable_M740; break;
case CPU_4510: OpcTable = OpcTable_4510; break;