1 | unit FormDisassembler;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
|
---|
7 | ExtCtrls, Disassembler;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TFormDisassembler }
|
---|
12 |
|
---|
13 | TFormDisassembler = class(TForm)
|
---|
14 | ListView1: TListView;
|
---|
15 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
16 | procedure FormCreate(Sender: TObject);
|
---|
17 | procedure FormDestroy(Sender: TObject);
|
---|
18 | procedure FormShow(Sender: TObject);
|
---|
19 | procedure ListView1Data(Sender: TObject; Item: TListItem);
|
---|
20 | public
|
---|
21 | Disassembler: TDisassembler;
|
---|
22 | procedure SelectAddress(Address: Word);
|
---|
23 | procedure ReloadList;
|
---|
24 | end;
|
---|
25 |
|
---|
26 | var
|
---|
27 | FormDisassembler: TFormDisassembler;
|
---|
28 |
|
---|
29 |
|
---|
30 | implementation
|
---|
31 |
|
---|
32 | {$R *.lfm}
|
---|
33 |
|
---|
34 | { TFormDisassembler }
|
---|
35 |
|
---|
36 | procedure TFormDisassembler.FormClose(Sender: TObject;
|
---|
37 | var CloseAction: TCloseAction);
|
---|
38 | begin
|
---|
39 | end;
|
---|
40 |
|
---|
41 | procedure TFormDisassembler.FormCreate(Sender: TObject);
|
---|
42 | begin
|
---|
43 | Disassembler := TDisassembler.Create;
|
---|
44 | end;
|
---|
45 |
|
---|
46 | procedure TFormDisassembler.FormDestroy(Sender: TObject);
|
---|
47 | begin
|
---|
48 | FreeAndNil(Disassembler);
|
---|
49 | end;
|
---|
50 |
|
---|
51 | procedure TFormDisassembler.FormShow(Sender: TObject);
|
---|
52 | begin
|
---|
53 | Disassembler.Disassemble;
|
---|
54 | ReloadList;
|
---|
55 | end;
|
---|
56 |
|
---|
57 | procedure TFormDisassembler.ListView1Data(Sender: TObject; Item: TListItem);
|
---|
58 | begin
|
---|
59 | if Item.Index < Disassembler.DecodedInstructions.Count then
|
---|
60 | with TDecodedInstruction(Disassembler.DecodedInstructions[Item.Index]) do begin
|
---|
61 | Item.Caption := IntToHex(Address, 4);
|
---|
62 | Item.Data := Disassembler.DecodedInstructions[Item.Index];
|
---|
63 | Item.SubItems.Add(GetOpcodesText);
|
---|
64 | Item.SubItems.Add(Name);
|
---|
65 | Item.SubItems.Add(Parameters);
|
---|
66 | end;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | procedure TFormDisassembler.SelectAddress(Address: Word);
|
---|
70 | var
|
---|
71 | Item: TListItem;
|
---|
72 | DecodedInstruction: TDecodedInstruction;
|
---|
73 | begin
|
---|
74 | DecodedInstruction := Disassembler.DecodedInstructions.SearchAddress(Address);
|
---|
75 | if Assigned(DecodedInstruction) then begin
|
---|
76 | Item := ListView1.Items[Disassembler.DecodedInstructions.IndexOf(DecodedInstruction)];
|
---|
77 | if Assigned(Item) then begin
|
---|
78 | Item.MakeVisible(False);
|
---|
79 | Item.Focused := True;
|
---|
80 | Item.Selected := True;
|
---|
81 | end;
|
---|
82 | end;
|
---|
83 | end;
|
---|
84 |
|
---|
85 | procedure TFormDisassembler.ReloadList;
|
---|
86 | begin
|
---|
87 | ListView1.Items.Count := Disassembler.DecodedInstructions.Count;
|
---|
88 | ListView1.Refresh;
|
---|
89 | end;
|
---|
90 |
|
---|
91 | end.
|
---|
92 |
|
---|