printinstrtostring.cpp

来自「nes游戏模拟器」· C++ 代码 · 共 1,708 行 · 第 1/4 页

CPP
1,708 行
字号

//------------------------------------------------------------------------------
// Name: PrintBIT()
// Desc: Prints the BIT instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintBIT(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "BIT"; // Name of the instruction being printed.

	// Depending on the opcode of the instruction, different addressing
	// modes apply. This means that different strings must be printed
	// depending on the addressing mode.
	switch (byOpcode)
	{
		case 0x24:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0x2C:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintBIT()


//------------------------------------------------------------------------------
// Name: PrintBMI()
// Desc: Prints the BMI instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintBMI(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "BMI"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Relative(strDest, strInstrName, wPC));
} // end PrintBMI()


//------------------------------------------------------------------------------
// Name: PrintBNE()
// Desc: Prints the BNE instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintBNE(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "BNE"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Relative(strDest, strInstrName, wPC));
} // end PrintBNE()


//------------------------------------------------------------------------------
// Name: PrintBPL()
// Desc: Prints the BPL instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintBPL(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "BPL"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Relative(strDest, strInstrName, wPC));
} // end PrintBPL()


//------------------------------------------------------------------------------
// Name: PrintBRK()
// Desc: Prints the BRK instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintBRK(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "BRK"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Implied(strDest, strInstrName, wPC));
} // end PrintBRK()

//------------------------------------------------------------------------------
// Name: PrintBVC()
// Desc: Prints the BVC instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintBVC(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "BVC"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Relative(strDest, strInstrName, wPC));
} // end PrintBVC()


//------------------------------------------------------------------------------
// Name: PrintBVS()
// Desc: Prints the BVS instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintBVS(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "BVS"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Relative(strDest, strInstrName, wPC));
} // end PrintBVS()


//------------------------------------------------------------------------------
// Name: PrintCLC()
// Desc: Prints the CLC instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintCLC(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "CLC"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Implied(strDest, strInstrName, wPC));
} // end PrintCLC()


//------------------------------------------------------------------------------
// Name: PrintCLD()
// Desc: Prints the CLD instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintCLD(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "CLD"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Implied(strDest, strInstrName, wPC));
} // end PrintCLD()


//------------------------------------------------------------------------------
// Name: PrintCLI()
// Desc: Prints the CLI instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintCLI(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "CLI"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Implied(strDest, strInstrName, wPC));
} // end PrintCLI()


//------------------------------------------------------------------------------
// Name: PrintCLV()
// Desc: Prints the CLV instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintCLV(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "CLV"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Implied(strDest, strInstrName, wPC));
} // end PrintCLV()


//------------------------------------------------------------------------------
// Name: PrintCMP()
// Desc: Prints the CMP instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintCMP(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "CMP"; // Name of the instruction being printed.

	// Depending on the opcode of the instruction, different addressing
	// modes apply. This means that different strings must be printed
	// depending on the addressing mode.
	switch (byOpcode)
	{
		case 0xC1:
			return (1 + PrintAddrMode_PreIndexedIndirect(strDest, strInstrName, wPC));
		case 0xC5:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0xC9:
			return (1 + PrintAddrMode_Immediate(strDest, strInstrName, wPC));
		case 0xCD:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0xD1:
			return (1 + PrintAddrMode_PostIndexedIndirect(strDest, strInstrName, wPC));
		case 0xD5:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0xD9:
			return (1 + PrintAddrMode_AbsoluteY(strDest, strInstrName, wPC));
		case 0xDD:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintCMP()


//------------------------------------------------------------------------------
// Name: PrintCPX()
// Desc: Prints the CPX instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintCPX(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "CPX"; // Name of the instruction being printed.

	// Depending on the opcode of the instruction, different addressing
	// modes apply. This means that different strings must be printed
	// depending on the addressing mode.
	switch (byOpcode)
	{
		case 0xE0:
			return (1 + PrintAddrMode_Immediate(strDest, strInstrName, wPC));
		case 0xE4:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0xEC:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintCPX()


//------------------------------------------------------------------------------
// Name: PrintCPY()
// Desc: Prints the CPY instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintCPY(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "CPY"; // Name of the instruction being printed.

	// Depending on the opcode of the instruction, different addressing
	// modes apply. This means that different strings must be printed
	// depending on the addressing mode.
	switch (byOpcode)
	{
		case 0xC0:
			return (1 + PrintAddrMode_Immediate(strDest, strInstrName, wPC));
		case 0xC4:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0xCC:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintCPY()


//------------------------------------------------------------------------------
// Name: PrintDEC()
// Desc: Prints the DEC instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintDEC(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "DEC"; // Name of the instruction being printed.

	// Depending on the opcode of the instruction, different addressing
	// modes apply. This means that different strings must be printed
	// depending on the addressing mode.
	switch (byOpcode)
	{
		case 0xC6:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0xCE:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0xD6:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0xDE:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintDEC()


//------------------------------------------------------------------------------
// Name: PrintDEX()
// Desc: Prints the DEX instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintDEX(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "DEX"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Implied(strDest, strInstrName, wPC));
} // end PrintDEX()


//------------------------------------------------------------------------------
// Name: PrintDEY()
// Desc: Prints the DEY instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintDEY(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "DEY"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Implied(strDest, strInstrName, wPC));
} // end PrintDEY()


//------------------------------------------------------------------------------
// Name: PrintEOR()
// Desc: Prints the EOR instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintEOR(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "EOR"; // Name of the instruction being printed.

	// Depending on the opcode of the instruction, different addressing
	// modes apply. This means that different strings must be printed
	// depending on the addressing mode.
	switch (byOpcode)
	{
		case 0x41:
			return (1 + PrintAddrMode_PreIndexedIndirect(strDest, strInstrName, wPC));
		case 0x45:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0x49:
			return (1 + PrintAddrMode_Immediate(strDest, strInstrName, wPC));
		case 0x4D:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0x51:
			return (1 + PrintAddrMode_PostIndexedIndirect(strDest, strInstrName, wPC));
		case 0x55:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0x59:
			return (1 + PrintAddrMode_AbsoluteY(strDest, strInstrName, wPC));
		case 0x5D:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintEOR()


//------------------------------------------------------------------------------
// Name: PrintINC()
// Desc: Prints the INC instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintINC(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "INC"; // Name of the instruction being printed.

	// Depending on the opcode of the instruction, different addressing
	// modes apply. This means that different strings must be printed
	// depending on the addressing mode.
	switch (byOpcode)
	{
		case 0xE6:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0xEE:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0xF6:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0xFE:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintINC()


//------------------------------------------------------------------------------
// Name: PrintINX()
// Desc: Prints the INX instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintINX(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "INX"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Implied(strDest, strInstrName, wPC));
} // end PrintINX()


//------------------------------------------------------------------------------
// Name: PrintINY()
// Desc: Prints the INY instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintINY(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "INY"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Implied(strDest, strInstrName, wPC));
} // end PrintINY()


//------------------------------------------------------------------------------
// Name: PrintJMP()
// Desc: Prints the JMP instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintJMP(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "JMP"; // Name of the instruction being printed.

	// Depending on the opcode of the instruction, different addressing
	// modes apply. This means that different strings must be printed
	// depending on the addressing mode.
	switch (byOpcode)
	{
		case 0x4C:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0x6C:
			return (1 + PrintAddrMode_Indirect(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintJMP()


//------------------------------------------------------------------------------
// Name: PrintJSR()
// Desc: Prints the JSR instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintJSR(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "JSR"; // Name of the instruction being printed.

	return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
} // end PrintJSR()


//------------------------------------------------------------------------------
// Name: PrintLDA()
// Desc: Prints the LDA instruction to a string and returns the number
//       of bytes for the entire instruction.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?