⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printinstrtostring.cpp

📁 nes游戏模拟器
💻 CPP
📖 第 1 页 / 共 4 页
字号:
//------------------------------------------------------------------------------
BYTE PrintLDA(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "LDA"; // 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 0xA1:
			return (1 + PrintAddrMode_PreIndexedIndirect(strDest, strInstrName, wPC));
		case 0xA5:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0xA9:
			return (1 + PrintAddrMode_Immediate(strDest, strInstrName, wPC));
		case 0xAD:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0xB1:
			return (1 + PrintAddrMode_PostIndexedIndirect(strDest, strInstrName, wPC));
		case 0xB5:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0xB9:
			return (1 + PrintAddrMode_AbsoluteY(strDest, strInstrName, wPC));
		case 0xBD:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintLDA()


//------------------------------------------------------------------------------
// Name: PrintLDX()
// Desc: Prints the LDX instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintLDX(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "LDX"; // 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 0xA6:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0xA2:
			return (1 + PrintAddrMode_Immediate(strDest, strInstrName, wPC));
		case 0xAE:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0xB6:
			return (1 + PrintAddrMode_ZeroPageY(strDest, strInstrName, wPC));
		case 0xBE:
			return (1 + PrintAddrMode_AbsoluteY(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintLDX()


//------------------------------------------------------------------------------
// Name: PrintLDY()
// Desc: Prints the LDY instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintLDY(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "LDY"; // 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 0xA4:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0xA0:
			return (1 + PrintAddrMode_Immediate(strDest, strInstrName, wPC));
		case 0xAC:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0xB4:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0xBC:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintLDY()


//------------------------------------------------------------------------------
// Name: PrintLSR()
// Desc: Prints the LSR instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintLSR(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "LSR"; // 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 0x46:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0x4A:
			return (1 + PrintAddrMode_Accumulator(strDest, strInstrName, wPC));
		case 0x4E:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0x56:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0x5E:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintLSR()


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

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


//------------------------------------------------------------------------------
// Name: PrintORA()
// Desc: Prints the ORA instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintORA(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "ORA"; // 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 0x01:
			return (1 + PrintAddrMode_PreIndexedIndirect(strDest, strInstrName, wPC));
		case 0x05:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0x09:
			return (1 + PrintAddrMode_Immediate(strDest, strInstrName, wPC));
		case 0x0D:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0x11:
			return (1 + PrintAddrMode_PostIndexedIndirect(strDest, strInstrName, wPC));
		case 0x15:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0x19:
			return (1 + PrintAddrMode_AbsoluteY(strDest, strInstrName, wPC));
		case 0x1D:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintORA()
	

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

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


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

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


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

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


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

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


//------------------------------------------------------------------------------
// Name: PrintROL()
// Desc: Prints the ROL instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintROL(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "ROL"; // 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 0x26:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0x2A:
			return (1 + PrintAddrMode_Accumulator(strDest, strInstrName, wPC));
		case 0x2E:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0x36:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0x3E:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintROL()


//------------------------------------------------------------------------------
// Name: PrintROR()
// Desc: Prints the ROR instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintROR(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "ROR"; // 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 0x66:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0x6A:
			return (1 + PrintAddrMode_Accumulator(strDest, strInstrName, wPC));
		case 0x6E:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0x76:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0x7E:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintROR()


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

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


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

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


//------------------------------------------------------------------------------
// Name: PrintSBC()
// Desc: Prints the SBC instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintSBC(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "SBC"; // 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 0xE1:
			return (1 + PrintAddrMode_PreIndexedIndirect(strDest, strInstrName, wPC));
		case 0xE5:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0xE9:
			return (1 + PrintAddrMode_Immediate(strDest, strInstrName, wPC));
		case 0xED:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0xF1:
			return (1 + PrintAddrMode_PostIndexedIndirect(strDest, strInstrName, wPC));
		case 0xF5:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0xF9:
			return (1 + PrintAddrMode_AbsoluteY(strDest, strInstrName, wPC));
		case 0xFD:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintSBC()


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

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


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

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


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

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


//------------------------------------------------------------------------------
// Name: PrintSTA()
// Desc: Prints the STA instruction to a string and returns the number
//       of bytes for the entire instruction.
//------------------------------------------------------------------------------
BYTE PrintSTA(LPSTR strDest, WORD wPC, BYTE byOpcode)
{
	LPSTR strInstrName = "STA"; // 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 0x81:
			return (1 + PrintAddrMode_PreIndexedIndirect(strDest, strInstrName, wPC));
		case 0x85:
			return (1 + PrintAddrMode_ZeroPage(strDest, strInstrName, wPC));
		case 0x8D:
			return (1 + PrintAddrMode_Absolute(strDest, strInstrName, wPC));
		case 0x91:
			return (1 + PrintAddrMode_PostIndexedIndirect(strDest, strInstrName, wPC));
		case 0x95:
			return (1 + PrintAddrMode_ZeroPageX(strDest, strInstrName, wPC));
		case 0x99:
			return (1 + PrintAddrMode_AbsoluteY(strDest, strInstrName, wPC));
		case 0x9D:
			return (1 + PrintAddrMode_AbsoluteX(strDest, strInstrName, wPC));
		default:
			return 0;
	}
} // end PrintSTA()


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

⌨️ 快捷键说明

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