2014-12-13 21:49:15 +00:00
using System ;
using System.Linq ;
using System.Collections.Generic ;
2014-12-13 20:52:52 +00:00
namespace BizHawk.Emulation.Common
{
2016-03-02 02:10:09 +00:00
/// <summary>
2017-04-26 14:10:00 +00:00
/// This service provides the means to generate disassembly by the core for a given CPU and memory domain
/// Tools such the debugger use this, but also LUA scripting, and tools like trace logging and code data logging can make use of this tool
/// If unavailable the debugger tool will still be available but disable the disassembly window but still be available if the <seealso cref="IDebuggable"/> service is available
2016-03-02 02:10:09 +00:00
/// </summary>
2014-12-13 21:49:15 +00:00
public interface IDisassemblable : IEmulatorService
2014-12-13 20:52:52 +00:00
{
/// <summary>
2017-04-26 14:10:00 +00:00
/// Gets or sets the CPUS that will be used to disassemble
/// Only values returned from <seealso cref="AvailableCpus"/> will be supported when Set
2014-12-13 20:52:52 +00:00
/// </summary>
string Cpu { get ; set ; }
2014-12-14 17:27:45 +00:00
/// <summary>
2017-04-26 14:10:00 +00:00
/// Gets the name of the Program Counter Register for the current CPU
2014-12-14 17:27:45 +00:00
/// </summary>
string PCRegisterName { get ; }
2014-12-13 20:52:52 +00:00
/// <summary>
2017-04-26 14:10:00 +00:00
/// Gets a list of CPUs that can be used when setting the CPU property
2014-12-13 20:52:52 +00:00
/// </summary>
2014-12-13 21:49:15 +00:00
IEnumerable < string > AvailableCpus { get ; }
2014-12-13 20:52:52 +00:00
/// <summary>
2017-04-26 14:10:00 +00:00
/// Returns a disassembly starting at address lasting for length, using the given domain
2014-12-13 20:52:52 +00:00
/// </summary>
string Disassemble ( MemoryDomain m , uint addr , out int length ) ;
}
2014-12-13 21:49:15 +00:00
/// <summary>
2017-04-27 17:02:08 +00:00
/// does sanity checking on CPU parameters
2014-12-13 21:49:15 +00:00
/// </summary>
public abstract class VerifiedDisassembler : IDisassemblable
{
2017-04-27 17:02:08 +00:00
private string _cpu ;
2014-12-13 21:49:15 +00:00
public virtual string Cpu
{
get
{
return _cpu ;
}
2017-04-27 16:56:33 +00:00
2014-12-13 21:49:15 +00:00
set
{
if ( ! AvailableCpus . Contains ( value ) )
2016-02-29 00:03:01 +00:00
{
2014-12-13 21:49:15 +00:00
throw new ArgumentException ( ) ;
2016-02-29 00:03:01 +00:00
}
2014-12-13 21:49:15 +00:00
_cpu = value ;
}
}
2014-12-14 17:17:22 +00:00
public abstract IEnumerable < string > AvailableCpus { get ; }
public abstract string PCRegisterName { get ; }
2014-12-13 21:49:15 +00:00
public abstract string Disassemble ( MemoryDomain m , uint addr , out int length ) ;
2017-04-26 14:10:00 +00:00
protected VerifiedDisassembler ( )
2014-12-13 21:49:15 +00:00
{
_cpu = AvailableCpus . First ( ) ;
}
}
2014-12-13 20:52:52 +00:00
}