Hi all,
I am writing a multi CPU disassembler, so am trying to abstract out the bits that are common to all target CPUs and just have the CPU specific stuff implemented in decendent classes.
So I have an abstract disassembler class :
TCPU = (tcNone,tc6502, tc65c02, tc65c02wd, tc6512, tc6809);
TCPUSet = SET OF TCPU;
TOpCode = Class(TObject)
OpStr : STRING;
OpBytes : INTEGER;
CPU : TCPUSet;
Valid : BOOLEAN;
CONSTRUCTOR Create;
END;
TADisassembler = Class(TObject)
PROTECTED
FOpCodes : ARRAY[$00..$FF]OF TOpCode;
FVerbose : BOOLEAN;
FCPU : TCPU;
FUNCTION CalcRelative8(RelOffset : BYTE) : WORD;
FUNCTION CalcRelative16(RelOffset : WORD) : WORD;
PROCEDURE DecodeInstruction; virtual; abstract;
PROCEDURE InitOpcodes; virtual; abstract;
PROCEDURE SetVerbose(NewValue : BOOLEAN);
PUBLIC
SymbolList : TSymbolList;
EntryPoints : TSymbolList;
Memory : TCPUmemory;
MemoryList : TMemoryList;
PROPERTY Verbose : BOOLEAN READ FVerbose WRITE SetVerbose;
PROPERTY CPU : TCPU READ FCPU WRITE FCPU;
CONSTRUCTOR Create;
DESTRUCTOR Destroy; override;
PROCEDURE Go; virtual; abstract;
PROCEDURE LoadFromFile(FileName : STRING;
PBaseAddr : DWORD);
PROCEDURE SetCPU(CPUType : INTEGER);
END;
Then my CPU specific stuff overrides / inherits. :
TBranch = (brNone,brRelative,brAbsolute,brRtsRti,brZPRelative);
TOpCode6502 = Class(TOpCode)
OpStr : STRING;
OpBytes : INTEGER;
CPU : TCPUSet;
Branch : TBranch;
Valid : BOOLEAN;
END;
TDisassembler6502 = Class(TADisassembler)
PROTECTED
PROCEDURE DecodeInstruction; override;
PROCEDURE InitOpcodes; override;
PROCEDURE MakeOpCode(OpNo : INTEGER;
InOpStr : STRING;
InOpBytes : INTEGER;
InCPU : TCPUSet;
InBranch : TBranch = brNone);
PUBLIC
CONSTRUCTOR Create;
DESTRUCTOR Destroy; override;
PROCEDURE Go; override;
END;
These are in seperate unit files. I have also written code for the virtual methods in TDisassembler6502.
When run the units appear to work however when The free method of TDisassembler6502 is called the program causes a GPF.
In my main program the disassembler is defined as :
VAR Disassember : TDisassembler6502;
It is createed in my initaliasation procedure with :
Disassember:=TDisassembler6502.Create;
I attempt to free it with :
This is where I get the GPF.
Any idea what the problem might be? If I single step the debugger doesn't even make it to the Destroy methods of either of the classes.
I can post the entire code of the units if wanted just trying to not flood the forum
Cheers.
Phill.