Line | |
---|
1 | unit UFormMain;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
|
---|
7 |
|
---|
8 | type
|
---|
9 |
|
---|
10 | { TFormMain }
|
---|
11 |
|
---|
12 | TFormMain = class(TForm)
|
---|
13 | Memo1: TMemo;
|
---|
14 | procedure FormShow(Sender: TObject);
|
---|
15 | private
|
---|
16 | procedure WriteExecute(Data: Byte);
|
---|
17 | public
|
---|
18 | end;
|
---|
19 |
|
---|
20 | var
|
---|
21 | FormMain: TFormMain;
|
---|
22 |
|
---|
23 |
|
---|
24 | implementation
|
---|
25 |
|
---|
26 | {$R *.lfm}
|
---|
27 |
|
---|
28 | uses
|
---|
29 | Cpu, Memory, Console, Channel;
|
---|
30 |
|
---|
31 | { TFormMain }
|
---|
32 |
|
---|
33 | procedure TFormMain.FormShow(Sender: TObject);
|
---|
34 | var
|
---|
35 | Cpu: TCpu;
|
---|
36 | Memory: TMemory;
|
---|
37 | Console: TConsole;
|
---|
38 | begin
|
---|
39 | Cpu := TCpu.Create;
|
---|
40 | try
|
---|
41 | Memory := TMemory.Create;
|
---|
42 | Memory.Size := 60000;
|
---|
43 | Memory.SetChannel(Cpu.Memory);
|
---|
44 | Console := TConsole.Create;
|
---|
45 | Console.OnWrite := WriteExecute;
|
---|
46 | Console.SetChannel(Cpu.IO);
|
---|
47 | Cpu.AddressWidth := bw24;
|
---|
48 | Cpu.WriteOpcode(opWidth24);
|
---|
49 | Cpu.WriteOpcode(opLoad);
|
---|
50 | Cpu.Write24(Ord('A'));
|
---|
51 | Cpu.WriteOpcode(opWidth24);
|
---|
52 | Cpu.WriteOpcode(opOutput);
|
---|
53 | Cpu.WriteAddress(0);
|
---|
54 | Cpu.WriteOpcode(opHalt);
|
---|
55 | Cpu.Run;
|
---|
56 | FreeAndNil(Console);
|
---|
57 | FreeAndNil(Memory);
|
---|
58 | finally
|
---|
59 | FreeAndNil(Cpu);
|
---|
60 | end;
|
---|
61 | end;
|
---|
62 |
|
---|
63 | procedure TFormMain.WriteExecute(Data: Byte);
|
---|
64 | begin
|
---|
65 | Memo1.Lines.Text := Memo1.Lines.Text + Chr(Data);
|
---|
66 | end;
|
---|
67 |
|
---|
68 | end.
|
---|
69 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.