Ignore:
Timestamp:
Jul 10, 2022, 12:37:58 AM (2 years ago)
Author:
chronos
Message:
  • Added: Interrupt handling.
Location:
branches/UltimatOS
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/UltimatOS

    • Property svn:ignore
      •  

        old new  
        22UltimatOS.lps
        33UltimatOS.res
         4UltimatOS.dbg
        45lib
  • branches/UltimatOS/Forms/UFormMain.lfm

    r30 r32  
    1010  OnCreate = FormCreate
    1111  OnDestroy = FormDestroy
     12  OnKeyUp = FormKeyUp
    1213  OnShow = FormShow
    1314  LCLVersion = '2.2.0.4'
     
    1718    Top = 8
    1819    Width = 640
     20    OnMouseMove = PaintBox1MouseMove
    1921    OnPaint = PaintBox1Paint
    2022  end
    21   object ButtonRun: TButton
     23  object ButtonStart: TButton
    2224    Left = 8
    2325    Height = 33
    2426    Top = 496
    2527    Width = 98
    26     Caption = 'Run'
    27     OnClick = ButtonRunClick
     28    Caption = 'Start'
     29    OnClick = ButtonStartClick
    2830    TabOrder = 0
    2931  end
     
    4446  end
    4547  object ButtonMemory: TButton
    46     Left = 128
     48    Left = 550
    4749    Height = 33
    4850    Top = 496
     
    5153    OnClick = ButtonMemoryClick
    5254    TabOrder = 2
     55  end
     56  object ButtonStop: TButton
     57    Left = 112
     58    Height = 33
     59    Top = 496
     60    Width = 98
     61    Caption = 'Stop'
     62    OnClick = ButtonStopClick
     63    TabOrder = 3
     64  end
     65  object ButtonRestart: TButton
     66    Left = 216
     67    Height = 33
     68    Top = 496
     69    Width = 98
     70    Caption = 'Restart'
     71    OnClick = ButtonRestartClick
     72    TabOrder = 4
     73  end
     74  object ButtonCompile: TButton
     75    Left = 8
     76    Height = 33
     77    Top = 536
     78    Width = 98
     79    Caption = 'Compile'
     80    OnClick = ButtonCompileClick
     81    TabOrder = 5
    5382  end
    5483  object Timer1: TTimer
  • branches/UltimatOS/Forms/UFormMain.pas

    r30 r32  
    1313  TFormMain = class(TForm)
    1414    ButtonMemory: TButton;
    15     ButtonRun: TButton;
     15    ButtonCompile: TButton;
     16    ButtonStart: TButton;
     17    ButtonStop: TButton;
     18    ButtonRestart: TButton;
    1619    Label1: TLabel;
    1720    MemoCode: TMemo;
    1821    PaintBox1: TPaintBox;
    1922    Timer1: TTimer;
     23    procedure ButtonCompileClick(Sender: TObject);
    2024    procedure ButtonMemoryClick(Sender: TObject);
    21     procedure ButtonRunClick(Sender: TObject);
     25    procedure ButtonRestartClick(Sender: TObject);
     26    procedure ButtonStartClick(Sender: TObject);
     27    procedure ButtonStopClick(Sender: TObject);
    2228    procedure FormCreate(Sender: TObject);
    2329    procedure FormDestroy(Sender: TObject);
     30    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    2431    procedure FormShow(Sender: TObject);
     32    procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
     33      Y: Integer);
    2534    procedure PaintBox1Paint(Sender: TObject);
    2635    procedure Timer1Timer(Sender: TObject);
    2736  private
    2837    procedure InitProgram;
     38    procedure UpdateInterface;
    2939  public
    3040    Machine: TMachine;
     
    4050
    4151uses
    42   UInstructionWriter, UFormMemory;
     52  UAssembler, UFormMemory;
    4353
    4454{ TFormMain }
     
    5060end;
    5161
    52 procedure TFormMain.ButtonRunClick(Sender: TObject);
     62procedure TFormMain.ButtonStartClick(Sender: TObject);
    5363begin
    5464  Machine.Reset;
    55   with TInstructionWriter.Create do
    56   try
    57     Memory := Machine.Cpu.Memory;
    58     Parse(MemoCode.Lines);
    59   finally
    60     Free;
    61   end;
    62   Machine.Cpu.Run;
    63   Label1.Caption := 'Executed instructions: ' + IntToStr(Machine.Cpu.ExecutedCount);
     65  ButtonCompile.Click;
     66  Machine.Running := True;
     67  UpdateInterface;
     68end;
     69
     70procedure TFormMain.ButtonStopClick(Sender: TObject);
     71begin
     72  Machine.Running := False;
     73  UpdateInterface;
    6474end;
    6575
     
    7080end;
    7181
     82procedure TFormMain.ButtonCompileClick(Sender: TObject);
     83begin
     84  with TAssembler.Create do
     85  try
     86    Memory := Machine.Cpu.Memory;
     87    Parse(MemoCode.Lines);
     88  finally
     89    Free;
     90  end;
     91end;
     92
     93procedure TFormMain.ButtonRestartClick(Sender: TObject);
     94begin
     95  ButtonStop.Click;
     96  ButtonStart.Click;
     97end;
     98
    7299procedure TFormMain.FormDestroy(Sender: TObject);
    73100begin
     
    75102end;
    76103
     104procedure TFormMain.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
     105  );
     106begin
     107  Machine.Keyboard.Press(Key);
     108end;
     109
    77110procedure TFormMain.FormShow(Sender: TObject);
    78111begin
     112  UpdateInterface;
     113end;
     114
     115procedure TFormMain.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
     116  Y: Integer);
     117begin
     118  Machine.Mouse.Move(X, Y);
    79119end;
    80120
     
    99139    PaintBox1.Repaint;
    100140  end;
     141  Label1.Caption := 'Executed instructions: ' + IntToStr(Machine.Cpu.ExecutedCount) + LineEnding +
     142    'Interrupts: ' + IntToStr(Machine.Cpu.InterruptCount);
    101143end;
    102144
     
    106148end;
    107149
     150procedure TFormMain.UpdateInterface;
     151begin
     152  ButtonStart.Enabled := not Machine.Running;
     153  ButtonStop.Enabled := Machine.Running;
     154  ButtonRestart.Enabled := not Machine.Running;
     155end;
     156
    108157end.
    109158
Note: See TracChangeset for help on using the changeset viewer.