public void ExecuteJumpReturn(byte instruction, AddressModes addressMode, int signature) { RegisterBankNumber fakeBank = new RegisterBankNumber { Value = cpu.PC >> 16 }; int addr = GetAddress(addressMode, signature, fakeBank); switch (instruction) { case OpcodeList.JSR_Absolute: case OpcodeList.JSR_AbsoluteIndexedIndirectWithX: cpu.Push(cpu.PC - 1, 2); cpu.JumpLong(addr); return; case OpcodeList.JSR_AbsoluteLong: cpu.Push(cpu.PC - 1, 3); cpu.JumpLong(addr); return; case OpcodeList.JMP_Absolute: case OpcodeList.JMP_AbsoluteLong: case OpcodeList.JMP_AbsoluteIndirect: case OpcodeList.JMP_AbsoluteIndexedIndirectWithX: case OpcodeList.JMP_AbsoluteIndirectLong: cpu.JumpLong(addr); return; // RTS, RTL, RTI case OpcodeList.RTI_StackImplied: cpu.Flags.SetFlags(cpu.Pull(1)); cpu.SyncFlags(); if (cpu.Flags.Emulation) { cpu.JumpShort(cpu.Pull(2)); } else { cpu.JumpLong(cpu.Pull(3)); } return; case OpcodeList.RTS_StackImplied: cpu.JumpShort(cpu.Pull(2) + 1); return; case OpcodeList.RTL_StackImplied: addr = cpu.Pull(3); cpu.JumpLong(addr + 1); return; default: throw new NotImplementedException("ExecuteJumpReturn() opcode not implemented: " + instruction.ToString("X2")); } }
public void ExecuteJumpReturn(byte instruction, AddressModes addressMode, int signature) { int addr = GetAddress(addressMode, signature, cpu.ProgramBank); switch (instruction) { case OpcodeList.JSR_Absolute: case OpcodeList.JSR_AbsoluteIndexedIndirectWithX: cpu.Push(cpu.PC); cpu.JumpShort(addr); return; case OpcodeList.JSR_AbsoluteLong: cpu.Push(cpu.ProgramBank); cpu.Push(cpu.PC); cpu.JumpLong(addr); return; case OpcodeList.JMP_Absolute: case OpcodeList.JMP_AbsoluteLong: case OpcodeList.JMP_AbsoluteIndirect: case OpcodeList.JMP_AbsoluteIndexedIndirectWithX: case OpcodeList.JMP_AbsoluteIndirectLong: cpu.JumpLong(addr); return; case OpcodeList.RTS_StackImplied: cpu.JumpShort(cpu.Pull(2)); return; case OpcodeList.RTI_StackImplied: cpu.Flags.SetFlags(cpu.Pull(1)); int address = cpu.Pull(2); if (!cpu.Flags.Emulation) { cpu.DataBank.Value = cpu.Pull(1); address += (cpu.DataBank.Value << 16); } cpu.JumpLong(address); cpu.SyncFlags(); return; case OpcodeList.RTL_StackImplied: addr = cpu.Pull(3); cpu.JumpLong(addr); return; default: throw new NotImplementedException("ExecuteJumpReturn() opcode not implemented: " + instruction.ToString("X2")); } }