source: trunk/Forms/FormDisassembler.pas

Last change on this file was 2, checked in by chronos, 16 months ago
  • Added: Initial development version.
File size: 2.2 KB
Line 
1unit FormDisassembler;
2
3interface
4
5uses
6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
7 ExtCtrls, Disassembler;
8
9type
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
26var
27 FormDisassembler: TFormDisassembler;
28
29
30implementation
31
32{$R *.lfm}
33
34{ TFormDisassembler }
35
36procedure TFormDisassembler.FormClose(Sender: TObject;
37 var CloseAction: TCloseAction);
38begin
39end;
40
41procedure TFormDisassembler.FormCreate(Sender: TObject);
42begin
43 Disassembler := TDisassembler.Create;
44end;
45
46procedure TFormDisassembler.FormDestroy(Sender: TObject);
47begin
48 FreeAndNil(Disassembler);
49end;
50
51procedure TFormDisassembler.FormShow(Sender: TObject);
52begin
53 Disassembler.Disassemble;
54 ReloadList;
55end;
56
57procedure TFormDisassembler.ListView1Data(Sender: TObject; Item: TListItem);
58begin
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;
67end;
68
69procedure TFormDisassembler.SelectAddress(Address: Word);
70var
71 Item: TListItem;
72 DecodedInstruction: TDecodedInstruction;
73begin
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;
83end;
84
85procedure TFormDisassembler.ReloadList;
86begin
87 ListView1.Items.Count := Disassembler.DecodedInstructions.Count;
88 ListView1.Refresh;
89end;
90
91end.
92
Note: See TracBrowser for help on using the repository browser.