Changeset 50 for branches/ByteArray
- Timestamp:
- Nov 2, 2023, 11:18:06 PM (13 months ago)
- Location:
- branches/ByteArray
- Files:
-
- 9 added
- 2 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ByteArray/ByteArray.lpi
r48 r50 14 14 <Icon Value="0"/> 15 15 </General> 16 <i18n> 17 <EnableI18N Value="True"/> 18 <OutDir Value="Languages"/> 19 </i18n> 16 20 <BuildModes> 17 <Item Name="Default" Default="True"/> 21 <Item Name="Debug" Default="True"/> 22 <Item Name="Release"> 23 <CompilerOptions> 24 <Version Value="11"/> 25 <Target> 26 <Filename Value="ByteArray"/> 27 </Target> 28 <SearchPaths> 29 <IncludeFiles Value="$(ProjOutDir)"/> 30 <OtherUnitFiles Value="Forms;Devices"/> 31 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/> 32 </SearchPaths> 33 <Parsing> 34 <SyntaxOptions> 35 <SyntaxMode Value="Delphi"/> 36 <CStyleOperator Value="False"/> 37 <AllowLabel Value="False"/> 38 <CPPInline Value="False"/> 39 </SyntaxOptions> 40 </Parsing> 41 <CodeGeneration> 42 <SmartLinkUnit Value="True"/> 43 <Optimizations> 44 <OptimizationLevel Value="3"/> 45 </Optimizations> 46 </CodeGeneration> 47 <Linking> 48 <Debugging> 49 <GenerateDebugInfo Value="False"/> 50 <DebugInfoType Value="dsDwarf2Set"/> 51 <UseExternalDbgSyms Value="True"/> 52 </Debugging> 53 <LinkSmart Value="True"/> 54 <Options> 55 <Win32> 56 <GraphicApplication Value="True"/> 57 </Win32> 58 </Options> 59 </Linking> 60 </CompilerOptions> 61 </Item> 62 <SharedMatrixOptions Count="2"> 63 <Item1 ID="282404543287" Targets="Common" Modes="Debug" Value="-g -gl -gh -CirotR -O1"/> 64 <Item2 ID="894445904508" Targets="Common" Modes="Release" Value="-CX -XX -O3"/> 65 </SharedMatrixOptions> 18 66 </BuildModes> 19 67 <PublishOptions> … … 171 219 <Filename Value="Project.pas"/> 172 220 <IsPartOfProject Value="True"/> 221 </Unit> 222 <Unit> 223 <Filename Value="Forms/FormStorage.pas"/> 224 <IsPartOfProject Value="True"/> 225 <ComponentName Value="FormStorage"/> 226 <HasResources Value="True"/> 227 <ResourceBaseClass Value="Form"/> 173 228 </Unit> 174 229 </Units> … … 182 237 <IncludeFiles Value="$(ProjOutDir)"/> 183 238 <OtherUnitFiles Value="Forms;Devices"/> 184 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS) "/>239 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/> 185 240 </SearchPaths> 186 241 <Parsing> 187 242 <SyntaxOptions> 188 243 <SyntaxMode Value="Delphi"/> 244 <CStyleOperator Value="False"/> 189 245 <IncludeAssertionCode Value="True"/> 246 <AllowLabel Value="False"/> 247 <CPPInline Value="False"/> 190 248 </SyntaxOptions> 191 249 </Parsing> -
branches/ByteArray/ByteArray.lpr
r48 r50 14 14 FormAssembler, Cpu, BigInt, Channel, Common.Memory, FrameBuffer, Device, Storage, 15 15 DeviceMapper, Machine, Disassembler, Instructions, Parser, Message, Assembler, 16 Serial, Mouse, FormSourceEditor, FormMessages, FormMemory, Common16 Serial, Mouse, FormSourceEditor, FormMessages, FormMemory, FormStorage, Common 17 17 { you can add units after this }; 18 18 -
branches/ByteArray/Cpu.pas
r47 r50 41 41 42 42 TInstructionEvent = procedure of object; 43 TCpuThread = class; 43 44 44 45 { TCpu } … … 46 47 TCpu = class 47 48 private 48 Instructions: array[TInstruction] of TInstructionEvent; 49 FHalted: Boolean; 50 FRunning: Boolean; 51 FThread: TCpuThread; 52 FInstructions: array[TInstruction] of TInstructionEvent; 53 FTicks: QWord; 49 54 procedure Push(Value: TBigInt; Size: TBigIntSize); 50 55 function Pop(Size: TBigIntSize): TBigInt; … … 84 89 procedure InstructionDecSize; 85 90 procedure InitInstructions; 91 procedure SetRunning(AValue: Boolean); 92 procedure Run; 93 procedure Step; 86 94 public 87 95 Regs: array[TRegIndex] of TBigInt; 88 96 PC: TBigInt; 89 97 SP: TBigInt; 90 Terminated: Boolean;91 98 DataWidth: TBigIntSize; 92 99 AddressWidth: TBigIntSize; … … 99 106 procedure WriteRegister(Reg: TRegIndex); 100 107 procedure Reset; 101 procedure Run;102 procedure St ep;108 procedure Start; 109 procedure Stop; 103 110 constructor Create; 104 111 destructor Destroy; override; 112 property Ticks: QWord read FTicks; 113 property Running: Boolean read FRunning write SetRunning; 114 property Halted: Boolean read FHalted; 105 115 end; 106 116 117 { TCpuThread } 118 119 TCpuThread = class(TThread) 120 Cpu: TCpu; 121 procedure Execute; override; 122 end; 123 124 107 125 implementation 126 127 { TCpuThread } 128 129 procedure TCpuThread.Execute; 130 begin 131 repeat 132 if not Cpu.Halted then Cpu.Step 133 else Sleep(1); 134 //Cpu.CheckInterreupts; 135 until Terminated; 136 end; 108 137 109 138 { TCpu } … … 128 157 procedure TCpu.InstructionHalt; 129 158 begin 130 Terminated := True;159 FHalted := True; 131 160 end; 132 161 … … 443 472 procedure TCpu.InitInstructions; 444 473 begin 445 Instructions[inNop] := InstructionNop; 446 Instructions[inHalt] := InstructionHalt; 447 Instructions[inLoadConst] := InstructionLoadConst; 448 Instructions[inLoadConstSize] := InstructionLoadConstSize; 449 Instructions[inLoad] := InstructionLoad; 450 Instructions[inLoadSize] := InstructionLoadSize; 451 Instructions[inLoadMem] := InstructionLoadMem; 452 Instructions[inLoadMemSize] := InstructionLoadMemSize; 453 Instructions[inStoreMem] := InstructionStoreMem; 454 Instructions[inStoreMemSize] := InstructionStoreMemSize; 455 Instructions[inJump] := InstructionJump; 456 Instructions[inJumpSize] := InstructionJumpSize; 457 Instructions[inJumpNotZero] := InstructionJumpNotZero; 458 Instructions[inJumpNotZeroSize] := InstructionJumpNotZeroSize; 459 Instructions[inJumpZero] := InstructionJumpZero; 460 Instructions[inJumpZeroSize] := InstructionJumpZeroSize; 461 Instructions[inJumpRel] := InstructionJumpRel; 462 Instructions[inJumpRelSize] := InstructionJumpRelSize; 463 Instructions[inCall] := InstructionCall; 464 Instructions[inCallSize] := InstructionCallSize; 465 Instructions[inRet] := InstructionRet; 466 Instructions[inRetSize] := InstructionRetSize; 467 Instructions[inPush] := InstructionPush; 468 Instructions[inPushSize] := InstructionPushSize; 469 Instructions[inPop] := InstructionPop; 470 Instructions[inPopSize] := InstructionPopSize; 471 Instructions[inInput] := InstructionInput; 472 Instructions[inInputSize] := InstructionInputSize; 473 Instructions[inOutput] := InstructionOutput; 474 Instructions[inOutputSize] := InstructionOutputSize; 475 Instructions[inInc] := InstructionInc; 476 Instructions[inIncSize] := InstructionIncSize; 477 Instructions[inDec] := InstructionDec; 478 Instructions[inDecSize] := InstructionDecSize; 474 FInstructions[inNop] := InstructionNop; 475 FInstructions[inHalt] := InstructionHalt; 476 FInstructions[inLoadConst] := InstructionLoadConst; 477 FInstructions[inLoadConstSize] := InstructionLoadConstSize; 478 FInstructions[inLoad] := InstructionLoad; 479 FInstructions[inLoadSize] := InstructionLoadSize; 480 FInstructions[inLoadMem] := InstructionLoadMem; 481 FInstructions[inLoadMemSize] := InstructionLoadMemSize; 482 FInstructions[inStoreMem] := InstructionStoreMem; 483 FInstructions[inStoreMemSize] := InstructionStoreMemSize; 484 FInstructions[inJump] := InstructionJump; 485 FInstructions[inJumpSize] := InstructionJumpSize; 486 FInstructions[inJumpNotZero] := InstructionJumpNotZero; 487 FInstructions[inJumpNotZeroSize] := InstructionJumpNotZeroSize; 488 FInstructions[inJumpZero] := InstructionJumpZero; 489 FInstructions[inJumpZeroSize] := InstructionJumpZeroSize; 490 FInstructions[inJumpRel] := InstructionJumpRel; 491 FInstructions[inJumpRelSize] := InstructionJumpRelSize; 492 FInstructions[inCall] := InstructionCall; 493 FInstructions[inCallSize] := InstructionCallSize; 494 FInstructions[inRet] := InstructionRet; 495 FInstructions[inRetSize] := InstructionRetSize; 496 FInstructions[inPush] := InstructionPush; 497 FInstructions[inPushSize] := InstructionPushSize; 498 FInstructions[inPop] := InstructionPop; 499 FInstructions[inPopSize] := InstructionPopSize; 500 FInstructions[inInput] := InstructionInput; 501 FInstructions[inInputSize] := InstructionInputSize; 502 FInstructions[inOutput] := InstructionOutput; 503 FInstructions[inOutputSize] := InstructionOutputSize; 504 FInstructions[inInc] := InstructionInc; 505 FInstructions[inIncSize] := InstructionIncSize; 506 FInstructions[inDec] := InstructionDec; 507 FInstructions[inDecSize] := InstructionDecSize; 508 end; 509 510 procedure TCpu.SetRunning(AValue: Boolean); 511 begin 512 if FRunning = AValue then Exit; 513 if AValue then Start 514 else Stop; 479 515 end; 480 516 … … 516 552 PC := 0; 517 553 SP := 0; 518 Terminated := False; 554 FHalted := False; 555 FTicks := 0; 519 556 end; 520 557 … … 522 559 begin 523 560 Reset; 524 while not Terminated do561 while not FHalted do 525 562 Step; 526 563 end; … … 531 568 begin 532 569 Instruction := TInstruction(Byte(Read(1))); 533 Instructions[Instruction]; 570 FInstructions[Instruction]; 571 Inc(FTicks); 572 end; 573 574 procedure TCpu.Start; 575 begin 576 if not Running then begin 577 Reset; 578 FThread := TCpuThread.Create(True); 579 FThread.Cpu := Self; 580 FThread.Start; 581 FRunning := True; 582 end; 583 end; 584 585 procedure TCpu.Stop; 586 begin 587 if Running then begin 588 FHalted := True; 589 FThread.Terminate; 590 FThread.WaitFor; 591 FreeAndNil(FThread); 592 FRunning := False; 593 end; 534 594 end; 535 595 … … 544 604 destructor TCpu.Destroy; 545 605 begin 606 Stop; 546 607 FreeAndNil(Memory); 547 608 FreeAndNil(IO); -
branches/ByteArray/Devices/Device.pas
r48 r50 33 33 end; 34 34 35 resourcestring 36 SNone = 'None'; 37 SKeyboard = 'Keyboard'; 38 SMouse = 'Mouse'; 39 SStorage = 'Storage'; 40 SScreen = 'Screen'; 41 SConsole = 'Console'; 42 STimer = 'Timer'; 43 35 44 const 36 DeviceClassText: array[TDeviceClass] of string = ('None', 'Keyboard', 'Mouse', 'Storage', 'Screen', 'Console', 'Timer'); 45 DeviceClassText: array[TDeviceClass] of string = (SNone, SKeyboard, SMouse, 46 SStorage, SScreen, SConsole, STimer); 37 47 38 48 -
branches/ByteArray/Devices/Memory.pas
r47 r50 17 17 public 18 18 Position: Integer; 19 procedure Assign(Source: TMemory); 19 20 function Read(Address: TBigInt; ASize: TBigIntSize): TBigInt; 20 21 function ReadPos(ASize: Byte): TBigInt; … … 22 23 procedure WritePos(ASize: Byte; Value: TBigInt); 23 24 procedure WriteStringPos(Value: string); 25 procedure WriteMemoryPos(Memory: TMemory); 24 26 function GetAddressCount: Integer; override; 25 27 procedure SetChannel(Channel: TChannel); override; 26 28 procedure Clean; 27 29 property Size: Integer read GetSize write SetSize; 30 destructor Destroy; override; 28 31 end; 29 32 … … 44 47 begin 45 48 FData := ReAllocMem(FData, AValue); 49 end; 50 51 procedure TMemory.Assign(Source: TMemory); 52 begin 53 Size := Source.Size; 54 if Size > 0 then 55 Move(Source.FData[0], FData[0], Size); 56 Position := Source.Position; 46 57 end; 47 58 … … 90 101 end; 91 102 103 procedure TMemory.WriteMemoryPos(Memory: TMemory); 104 begin 105 if Memory.Size > 0 then begin 106 if Position + Memory.Size > Size then Size := Position + Memory.Size; 107 Move(Memory.FData[0], FData[Position], Memory.Size); 108 Inc(Position, Memory.Size); 109 end; 110 end; 111 92 112 function TMemory.GetAddressCount: Integer; 93 113 begin … … 106 126 end; 107 127 128 destructor TMemory.Destroy; 129 begin 130 Size := 0; 131 inherited; 132 end; 133 108 134 end. 109 135 -
branches/ByteArray/Devices/Storage.pas
r47 r50 13 13 private 14 14 FFileName: string; 15 function GetSize: Integer; 15 16 procedure SetFileName(AValue: string); 17 procedure SetSize(AValue: Integer); 16 18 public 17 19 FFile: TFileStream; … … 24 26 destructor Destroy; override; 25 27 property FileName: string read FFileName write SetFileName; 28 property Size: Integer read GetSize write SetSize; 26 29 end; 27 30 … … 40 43 else FFile := TFileStream.Create(FFileName, fmCreate); 41 44 end; 45 end; 46 47 function TStorage.GetSize: Integer; 48 begin 49 Result := FFile.Size; 50 end; 51 52 procedure TStorage.SetSize(AValue: Integer); 53 begin 54 FFile.Size := AValue; 42 55 end; 43 56 -
branches/ByteArray/Forms/FormAssembler.lfm
r46 r50 1 1 object FormAssembler: TFormAssembler 2 Left = 5092 Left = 728 3 3 Height = 719 4 Top = 3 904 Top = 384 5 5 Width = 1106 6 6 Caption = 'Assembler' -
branches/ByteArray/Forms/FormConsole.lfm
r45 r50 1 1 object FormConsole: TFormConsole 2 Left = 5263 Height = 6 554 Top = 4485 Width = 9472 Left = 780 3 Height = 689 4 Top = 399 5 Width = 1002 6 6 Caption = 'Console' 7 ClientHeight = 6 558 ClientWidth = 9477 ClientHeight = 689 8 ClientWidth = 1002 9 9 DesignTimePPI = 144 10 10 LCLVersion = '2.2.6.0' 11 11 object Memo1: TMemo 12 12 Left = 0 13 Height = 6 5513 Height = 689 14 14 Top = 0 15 Width = 94715 Width = 1002 16 16 Align = alClient 17 17 Anchors = [akLeft, akRight, akBottom] -
branches/ByteArray/Forms/FormDisassembler.lfm
r46 r50 1 1 object FormDisassembler: TFormDisassembler 2 Left = 49 02 Left = 491 3 3 Height = 746 4 Top = 3 004 Top = 324 5 5 Width = 1056 6 6 Caption = 'Disassembler' … … 8 8 ClientWidth = 1056 9 9 DesignTimePPI = 144 10 LCLVersion = '2.0.10.0' 10 OnCreate = FormCreate 11 OnDestroy = FormDestroy 12 OnShow = FormShow 13 LCLVersion = '2.2.6.0' 11 14 object MemoCode: TMemo 12 15 Left = 8 -
branches/ByteArray/Forms/FormDisassembler.pas
r46 r50 4 4 5 5 uses 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls ;6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Disassembler; 7 7 8 8 type … … 12 12 TFormDisassembler = class(TForm) 13 13 MemoCode: TMemo; 14 procedure FormCreate(Sender: TObject); 15 procedure FormDestroy(Sender: TObject); 16 procedure FormShow(Sender: TObject); 14 17 private 15 18 16 19 public 17 20 Disassembler: TDisassembler; 18 21 end; 19 22 … … 26 29 {$R *.lfm} 27 30 31 { TFormDisassembler } 32 33 procedure TFormDisassembler.FormCreate(Sender: TObject); 34 begin 35 Disassembler := TDisassembler.Create; 36 end; 37 38 procedure TFormDisassembler.FormDestroy(Sender: TObject); 39 begin 40 FreeAndNil(Disassembler); 41 end; 42 43 procedure TFormDisassembler.FormShow(Sender: TObject); 44 begin 45 Disassembler.Disassemble(MemoCode.Lines); 46 end; 47 28 48 end. 29 49 -
branches/ByteArray/Forms/FormMain.lfm
r48 r50 1 1 object FormMain: TFormMain 2 Left = 5 993 Height = 7124 Top = 5015 Width = 1 0142 Left = 535 3 Height = 993 4 Top = 247 5 Width = 1491 6 6 Caption = 'ByteArray' 7 7 DesignTimePPI = 144 … … 23 23 Caption = 'View' 24 24 object MenuItemViewConsole: TMenuItem 25 Caption = 'Console' 26 OnClick = MenuItemViewConsoleClick 25 Action = AConsole 27 26 end 28 27 object MenuItemViewScreen: TMenuItem 29 Caption = 'Screen' 30 OnClick = MenuItemViewScreenClick 28 Action = AScreen 31 29 end 32 30 object MenuItemViewStorage: TMenuItem 33 Caption = 'Storage'31 Action = AStorage 34 32 end 35 33 object MenuItem7: TMenuItem … … 50 48 object MenuItem5: TMenuItem 51 49 Action = ADebugger 50 end 51 object MenuItem8: TMenuItem 52 Action = ADisassembler 52 53 end 53 54 end … … 82 83 ShortCut = 122 83 84 end 85 object ADisassembler: TAction 86 Caption = 'Disassembler' 87 OnExecute = ADisassemblerExecute 88 end 89 object AStorage: TAction 90 Caption = 'Storage' 91 OnExecute = AStorageExecute 92 end 93 object AScreen: TAction 94 Caption = 'Screen' 95 OnExecute = AScreenExecute 96 end 97 object AConsole: TAction 98 Caption = 'Console' 99 OnExecute = AConsoleExecute 100 end 84 101 end 85 102 object PersistentForm1: TPersistentForm -
branches/ByteArray/Forms/FormMain.pas
r48 r50 6 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ActnList, 7 7 FormConsole, FormScreen, Machine, Common.PersistentForm, FormSourceEditor, 8 FormMemory, Common.FormEx ;8 FormMemory, Common.FormEx, FormDisassembler, FormStorage; 9 9 10 10 type … … 13 13 14 14 TFormMain = class(TFormEx) 15 AConsole: TAction; 16 AScreen: TAction; 17 AStorage: TAction; 18 ADisassembler: TAction; 15 19 AFullscreen: TAction; 16 20 AMemory: TAction; … … 28 32 MenuItem6: TMenuItem; 29 33 MenuItem7: TMenuItem; 34 MenuItem8: TMenuItem; 30 35 PersistentForm1: TPersistentForm; 31 36 Separator1: TMenuItem; … … 34 39 MenuItemViewStorage: TMenuItem; 35 40 MenuItemViewConsole: TMenuItem; 41 procedure AConsoleExecute(Sender: TObject); 36 42 procedure ADebuggerExecute(Sender: TObject); 43 procedure ADisassemblerExecute(Sender: TObject); 37 44 procedure AExitExecute(Sender: TObject); 38 45 procedure AFullscreenExecute(Sender: TObject); 39 46 procedure AMemoryExecute(Sender: TObject); 47 procedure AScreenExecute(Sender: TObject); 40 48 procedure ASourceEditorExecute(Sender: TObject); 49 procedure AStorageExecute(Sender: TObject); 41 50 procedure FormCreate(Sender: TObject); 42 51 procedure FormDestroy(Sender: TObject); 43 52 procedure FormShow(Sender: TObject); 44 procedure MenuItemViewConsoleClick(Sender: TObject);45 procedure MenuItemViewScreenClick(Sender: TObject);46 53 private 47 54 FormScreen: TFormScreen; … … 49 56 FormMemory: TFormMemory; 50 57 FormSourceEditor: TFormSourceEditor; 58 FormDisassembler: TFormDisassembler; 59 FormStorage: TFormStorage; 51 60 Machine: TMachine; 52 61 procedure InitMachine; … … 70 79 begin 71 80 DockForm(FormScreen, Self); 72 Machine. Run;81 Machine.PowerOn; 73 82 end; 74 83 … … 84 93 end; 85 94 86 procedure TFormMain.AExitExecute(Sender: TObject);87 begin88 Close;89 end;90 91 procedure TFormMain.AFullscreenExecute(Sender: TObject);92 begin93 PersistentForm1.SetFullScreen(not PersistentForm1.FormFullScreen);94 end;95 96 procedure TFormMain.AMemoryExecute(Sender: TObject);97 begin98 if not Assigned(FormMemory) then begin99 FormMemory := TFormMemory.Create(nil);100 FormMemory.Memory := Machine.Memory;101 end;102 FormMemory.Show;103 end;104 105 procedure TFormMain.ADebuggerExecute(Sender: TObject);106 begin107 108 end;109 110 procedure TFormMain.ASourceEditorExecute(Sender: TObject);111 begin112 if not Assigned(FormSourceEditor) then begin113 FormSourceEditor := TFormSourceEditor.Create(nil);114 end;115 FormSourceEditor.Show;116 end;117 118 95 procedure TFormMain.FormDestroy(Sender: TObject); 119 96 begin … … 122 99 if Assigned(FormConsole) then FreeAndNil(FormConsole); 123 100 if Assigned(FormMemory) then FreeAndNil(FormMemory); 101 if Assigned(FormDisassembler) then FreeAndNil(FormDisassembler); 102 if Assigned(FormStorage) then FreeAndNil(FormStorage); 124 103 FreeAndNil(Machine); 125 104 end; 126 105 127 procedure TFormMain.MenuItemViewConsoleClick(Sender: TObject); 106 procedure TFormMain.AExitExecute(Sender: TObject); 107 begin 108 Close; 109 end; 110 111 procedure TFormMain.AFullscreenExecute(Sender: TObject); 112 begin 113 PersistentForm1.SetFullScreen(not PersistentForm1.FormFullScreen); 114 end; 115 116 procedure TFormMain.AMemoryExecute(Sender: TObject); 117 begin 118 if not Assigned(FormMemory) then begin 119 FormMemory := TFormMemory.Create(nil); 120 FormMemory.Memory := Machine.Memory; 121 end; 122 FormMemory.Show; 123 end; 124 125 procedure TFormMain.AScreenExecute(Sender: TObject); 126 begin 127 FormScreen.Show; 128 end; 129 130 procedure TFormMain.ADebuggerExecute(Sender: TObject); 131 begin 132 end; 133 134 procedure TFormMain.AConsoleExecute(Sender: TObject); 128 135 begin 129 136 FormConsole.Show; 130 137 end; 131 138 132 procedure TFormMain.MenuItemViewScreenClick(Sender: TObject); 133 begin 134 FormScreen.Show; 139 procedure TFormMain.ADisassemblerExecute(Sender: TObject); 140 begin 141 if not Assigned(FormDisassembler) then 142 FormDisassembler := TFormDisassembler.Create(nil); 143 FormDisassembler.Disassembler.Memory := Machine.Memory; 144 FormDisassembler.Show; 145 end; 146 147 procedure TFormMain.ASourceEditorExecute(Sender: TObject); 148 begin 149 if not Assigned(FormSourceEditor) then begin 150 FormSourceEditor := TFormSourceEditor.Create(nil); 151 FormSourceEditor.Machine := Machine; 152 end; 153 FormSourceEditor.Show; 154 end; 155 156 procedure TFormMain.AStorageExecute(Sender: TObject); 157 begin 158 if not Assigned(FormStorage) then begin 159 FormStorage := TFormStorage.Create(nil); 160 FormStorage.Storage := Machine.Storage; 161 end; 162 FormStorage.Show; 135 163 end; 136 164 -
branches/ByteArray/Forms/FormMemory.lfm
r46 r50 1 1 object FormMemory: TFormMemory 2 Left = 5222 Left = 706 3 3 Height = 866 4 Top = 2564 Top = 311 5 5 Width = 1150 6 6 Caption = 'Memory' … … 8 8 ClientWidth = 1150 9 9 DesignTimePPI = 144 10 OnShow = FormShow 10 11 LCLVersion = '2.2.6.0' 11 12 object ListViewMemory: TListView -
branches/ByteArray/Forms/FormMemory.pas
r48 r50 14 14 ListViewMemory: TListView; 15 15 Timer1: TTimer; 16 procedure FormShow(Sender: TObject); 16 17 procedure ListViewMemoryData(Sender: TObject; Item: TListItem); 17 18 procedure Timer1Timer(Sender: TObject); … … 57 58 end; 58 59 60 procedure TFormMemory.FormShow(Sender: TObject); 61 begin 62 Reload; 63 end; 64 59 65 procedure TFormMemory.Timer1Timer(Sender: TObject); 60 66 begin -
branches/ByteArray/Forms/FormScreen.lfm
r45 r50 1 1 object FormScreen: TFormScreen 2 Left = 5272 Left = 815 3 3 Height = 676 4 Top = 3764 Top = 406 5 5 Width = 931 6 6 Caption = 'Screen' -
branches/ByteArray/Forms/FormSourceEditor.lfm
r47 r50 1 1 object FormSourceEditor: TFormSourceEditor 2 Left = 5912 Left = 818 3 3 Height = 681 4 Top = 4 724 Top = 403 5 5 Width = 926 6 6 Caption = 'Source editor' … … 70 70 end 71 71 end 72 object MenuItem9: TMenuItem 73 Caption = 'Run' 74 object MenuItem11: TMenuItem 75 Action = ACompile 76 end 77 object MenuItem10: TMenuItem 78 Action = ARun 79 end 80 object MenuItem12: TMenuItem 81 Action = APause 82 end 83 object MenuItem17: TMenuItem 84 Action = AStop 85 end 86 object MenuItem13: TMenuItem 87 Action = AStepIn 88 end 89 object MenuItem14: TMenuItem 90 Action = AStepOver 91 end 92 object MenuItem15: TMenuItem 93 Action = AStepOut 94 end 95 object MenuItem16: TMenuItem 96 Action = ARunToCursor 97 end 98 end 72 99 end 73 100 object ActionList1: TActionList … … 103 130 OnExecute = ACloseExecute 104 131 end 132 object ARun: TAction 133 Caption = 'Run' 134 OnExecute = ARunExecute 135 end 136 object ACompile: TAction 137 Caption = 'Compile' 138 OnExecute = ACompileExecute 139 end 140 object ARunToCursor: TAction 141 Caption = 'Run to cursor' 142 end 143 object AStepIn: TAction 144 Caption = 'Step in' 145 end 146 object AStepOut: TAction 147 Caption = 'Step out' 148 end 149 object AStepOver: TAction 150 Caption = 'Step over' 151 end 152 object APause: TAction 153 Caption = 'Pause' 154 end 155 object AStop: TAction 156 Caption = 'Stop' 157 OnExecute = AStopExecute 158 end 105 159 end 106 160 end -
branches/ByteArray/Forms/FormSourceEditor.pas
r48 r50 5 5 uses 6 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Menus, 7 ActnList, FormMessages, FormAssembler, Project, Common.FormEx; 7 ActnList, FormMessages, FormAssembler, Project, Common.FormEx, Assembler, 8 Machine, Memory; 8 9 9 10 type … … 13 14 TFormSourceEditor = class(TFormEx) 14 15 AClose: TAction; 16 ACompile: TAction; 17 AStop: TAction; 18 APause: TAction; 19 AStepOver: TAction; 20 AStepOut: TAction; 21 AStepIn: TAction; 22 ARunToCursor: TAction; 23 ARun: TAction; 15 24 ANew: TAction; 16 25 ASaveAs: TAction; … … 22 31 MainMenu1: TMainMenu; 23 32 MenuItem1: TMenuItem; 33 MenuItem10: TMenuItem; 34 MenuItem11: TMenuItem; 35 MenuItem12: TMenuItem; 36 MenuItem13: TMenuItem; 37 MenuItem14: TMenuItem; 38 MenuItem15: TMenuItem; 39 MenuItem16: TMenuItem; 40 MenuItem17: TMenuItem; 24 41 MenuItem2: TMenuItem; 25 42 MenuItem3: TMenuItem; … … 29 46 MenuItem7: TMenuItem; 30 47 MenuItem8: TMenuItem; 48 MenuItem9: TMenuItem; 31 49 Separator1: TMenuItem; 32 50 PanelBottom: TPanel; … … 34 52 Splitter1: TSplitter; 35 53 procedure ACloseExecute(Sender: TObject); 54 procedure ACompileExecute(Sender: TObject); 36 55 procedure AExitExecute(Sender: TObject); 37 56 procedure ANewExecute(Sender: TObject); 38 57 procedure AOpenExecute(Sender: TObject); 58 procedure ARunExecute(Sender: TObject); 39 59 procedure ASaveAsExecute(Sender: TObject); 40 60 procedure ASaveExecute(Sender: TObject); 61 procedure AStopExecute(Sender: TObject); 41 62 procedure FormCreate(Sender: TObject); 42 63 procedure FormDestroy(Sender: TObject); 43 64 procedure FormShow(Sender: TObject); 44 65 public 66 Assembler: TAssembler; 45 67 FormMessages: TFormMessages; 46 68 FormAssembler: TFormAssembler; 47 69 Project: TProject; 70 CompiledProgram: TMemory; 71 Machine: TMachine; 48 72 procedure DockInit; 49 73 procedure UpdateInterface; … … 62 86 procedure TFormSourceEditor.FormCreate(Sender: TObject); 63 87 begin 88 CompiledProgram := TMemory.Create; 89 Assembler := TAssembler.Create; 64 90 FormMessages := TFormMessages.Create(nil); 65 91 FormAssembler := TFormAssembler.Create(nil); … … 82 108 end; 83 109 110 procedure TFormSourceEditor.ACompileExecute(Sender: TObject); 111 begin 112 AStop.Execute; 113 with Assembler do begin 114 Compile(FormAssembler.SynEdit1.Lines.Text); 115 //Memory.SaveToFile('compiled.bin'); 116 CompiledProgram.Assign(Memory); 117 Machine.Memory.Position := 0; 118 Machine.Memory.WriteMemoryPos(CompiledProgram); 119 end; 120 if FormMessages.Visible then 121 FormMessages.Reload; 122 end; 123 84 124 procedure TFormSourceEditor.AOpenExecute(Sender: TObject); 85 125 var … … 93 133 OpenDialog.Free; 94 134 end; 135 end; 136 137 procedure TFormSourceEditor.ARunExecute(Sender: TObject); 138 begin 139 ACompile.Execute; 140 Machine.PowerOn; 95 141 end; 96 142 … … 113 159 end; 114 160 161 procedure TFormSourceEditor.AStopExecute(Sender: TObject); 162 begin 163 Machine.PowerOff; 164 end; 165 115 166 procedure TFormSourceEditor.FormDestroy(Sender: TObject); 116 167 begin 117 168 FreeAndNil(FormAssembler); 118 169 FreeAndNil(FormMessages); 170 FreeAndNil(Assembler); 171 FreeAndNil(CompiledProgram); 119 172 end; 120 173 -
branches/ByteArray/Machine.pas
r45 r50 18 18 Serial: TSerial; 19 19 DeviceMapper: TDeviceMapper; 20 procedure Run; 20 procedure PowerOn; 21 procedure PowerOff; 21 22 constructor Create; 22 23 destructor Destroy; override; … … 28 29 { TMachine } 29 30 30 procedure TMachine. Run;31 procedure TMachine.PowerOn; 31 32 begin 32 Cpu.Run; 33 Cpu.Start; 34 end; 35 36 procedure TMachine.PowerOff; 37 begin 38 Cpu.Stop; 33 39 end; 34 40 … … 54 60 FreeAndNil(DeviceMapper); 55 61 FreeAndNil(FrameBuffer); 62 FreeAndNil(Storage); 56 63 FreeAndNil(Memory); 57 64 FreeAndNil(Serial); -
branches/ByteArray/Parser.pas
r46 r50 55 55 implementation 56 56 57 resourcestring 58 SUnknownCharacter = 'Unknown character %s'; 59 57 60 { TParserPos } 58 61 … … 153 156 Break; 154 157 end else 155 Error( 'Unknown character ' + C, Pos.Pos);158 Error(Format(SUnknownCharacter, [C]), Pos.Pos); 156 159 end else 157 160 if State = psIdentifier then begin
Note:
See TracChangeset
for help on using the changeset viewer.