Changeset 35


Ignore:
Timestamp:
Jul 14, 2022, 11:29:01 PM (21 months ago)
Author:
chronos
Message:
  • Added: Cpu state window.
Location:
branches/UltimatOS
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/UltimatOS/Forms/UFormMain.lfm

    r34 r35  
    9090    ParentColor = False
    9191  end
     92  object ButtonCpu: TButton
     93    Left = 512
     94    Height = 38
     95    Top = 571
     96    Width = 113
     97    Caption = 'CPU'
     98    OnClick = ButtonCpuClick
     99    TabOrder = 6
     100  end
    92101  object Timer1: TTimer
    93102    Interval = 20
  • branches/UltimatOS/Forms/UFormMain.pas

    r34 r35  
    55uses
    66  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
    7   UMachine;
     7  UMachine, Math;
    88
    99type
     
    1414    ButtonMemory: TButton;
    1515    ButtonCompile: TButton;
     16    ButtonCpu: TButton;
    1617    ButtonStart: TButton;
    1718    ButtonStop: TButton;
     
    2425    Timer2: TTimer;
    2526    procedure ButtonCompileClick(Sender: TObject);
     27    procedure ButtonCpuClick(Sender: TObject);
    2628    procedure ButtonMemoryClick(Sender: TObject);
    2729    procedure ButtonRestartClick(Sender: TObject);
     
    5456
    5557uses
    56   UAssembler, UFormMemory;
     58  UAssembler, UFormMemory, UFormCpu;
    5759
    5860{ TFormMain }
     
    8082procedure TFormMain.ButtonMemoryClick(Sender: TObject);
    8183begin
     84  if not Assigned(FormMemory) then FormMemory := TFormMemory.Create(nil);
    8285  FormMemory.Memory := Machine.Memory;
    8386  FormMemory.Show;
     
    9396    Free;
    9497  end;
     98end;
     99
     100procedure TFormMain.ButtonCpuClick(Sender: TObject);
     101begin
     102  if not Assigned(FormCpu) then FormCpu := TFormCpu.Create(nil);
     103  FormCpu.Cpu := Machine.Cpu;
     104  FormCpu.Show;
    95105end;
    96106
     
    143153    PaintBox1.Repaint;
    144154  end;
    145   Label1.Caption := 'Executed instructions: ' + IntToStr(Machine.Cpu.ExecutedCount) + LineEnding +
     155  Label1.Caption := 'Executed instructions: ' + IntToStr(Machine.Cpu.Ticks) + LineEnding +
    146156    'Interrupts: ' + IntToStr(Machine.Cpu.InterruptCount);
    147157end;
    148158
    149159procedure TFormMain.Timer2Timer(Sender: TObject);
     160var
     161  TicksPerSecond: Int64;
    150162begin
    151   Label2.Caption := 'Ticks/s: ' + IntToStr(Machine.Cpu.ExecutedCount - LastTicks);
    152   LastTicks := Machine.Cpu.ExecutedCount;
     163  if Machine.Cpu.Ticks > LastTicks then TicksPerSecond := Machine.Cpu.Ticks - LastTicks
     164    else TicksPerSecond := Machine.Cpu.Ticks;
     165  Label2.Caption := 'Ticks/s: ' + IntToStr(TicksPerSecond);
     166  LastTicks := Machine.Cpu.Ticks;
    153167end;
    154168
  • branches/UltimatOS/UCpu.pas

    r34 r35  
    8282    procedure InstructionDisableInt;
    8383  public
    84     ExecutedCount: Integer;
     84    Ticks: Int64;
    8585    InterruptCount: Integer;
    8686    Terminated: Boolean;
     
    159159  if AValue and not Assigned(FCpuThread) then begin
    160160    FCpuThread := TCpuThread.Create(True);
    161     FCpuThread.FreeOnTerminate := True;
     161    FCpuThread.FreeOnTerminate := False;
    162162    FCpuThread.Cpu := Self;
    163163    FCpuThread.Start;
     
    488488    FInstructionHandlers[Instruction]
    489489    else raise Exception.Create('Missing handler for instruction ' + IntToStr(Integer(Instruction)));
    490   Inc(ExecutedCount);
     490  Inc(Ticks);
    491491end;
    492492
     
    496496  IP := 0;
    497497  SP := 0;
    498   ExecutedCount := 0;
     498  Ticks := 0;
    499499  InterruptEnabled := True;
    500500  InterruptPending := False;
  • branches/UltimatOS/UltimatOS.lpi

    r32 r35  
    107107        <ResourceBaseClass Value="Form"/>
    108108      </Unit>
     109      <Unit>
     110        <Filename Value="Forms/UFormCpu.pas"/>
     111        <IsPartOfProject Value="True"/>
     112        <ComponentName Value="FormCpu"/>
     113        <ResourceBaseClass Value="Form"/>
     114      </Unit>
    109115    </Units>
    110116  </ProjectOptions>
  • branches/UltimatOS/UltimatOS.lpr

    r32 r35  
    1111  {$ENDIF}
    1212  Interfaces, // this includes the LCL widgetset
    13   Forms, UFormMain, UMachine, UCpu, UMemory, UAssembler, UFormMemory
    14   { you can add units after this };
     13  Forms, UFormMain, UMachine, UCpu, UMemory, UAssembler, UFormMemory, UFormCpu;
    1514
    1615{$R *.res}
     
    2120  Application.Initialize;
    2221  Application.CreateForm(TFormMain, FormMain);
    23   Application.CreateForm(TFormMemory, FormMemory);
    2422  Application.Run;
    2523end.
Note: See TracChangeset for help on using the changeset viewer.