Changeset 30


Ignore:
Timestamp:
Jul 5, 2022, 8:28:18 PM (22 months ago)
Author:
chronos
Message:
  • Modified: Improved sample code execution.
  • Added: Memory map form.
Location:
branches/UltimatOS
Files:
3 added
7 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/UltimatOS

    • Property svn:ignore set to
      UltimatOS
      UltimatOS.lps
      UltimatOS.res
      lib
  • branches/UltimatOS/Forms/UFormMain.lfm

    r29 r30  
    3636    TabOrder = 1
    3737  end
     38  object Label1: TLabel
     39    Left = 662
     40    Height = 22
     41    Top = 500
     42    Width = 68
     43    Caption = 'Instrukcí:'
     44  end
     45  object ButtonMemory: TButton
     46    Left = 128
     47    Height = 33
     48    Top = 496
     49    Width = 98
     50    Caption = 'Memory'
     51    OnClick = ButtonMemoryClick
     52    TabOrder = 2
     53  end
    3854  object Timer1: TTimer
    3955    Interval = 20
  • branches/UltimatOS/Forms/UFormMain.pas

    r29 r30  
    1212
    1313  TFormMain = class(TForm)
     14    ButtonMemory: TButton;
    1415    ButtonRun: TButton;
     16    Label1: TLabel;
    1517    MemoCode: TMemo;
    1618    PaintBox1: TPaintBox;
    1719    Timer1: TTimer;
     20    procedure ButtonMemoryClick(Sender: TObject);
    1821    procedure ButtonRunClick(Sender: TObject);
    1922    procedure FormCreate(Sender: TObject);
     
    3740
    3841uses
    39   UInstructionWriter;
     42  UInstructionWriter, UFormMemory;
    4043
    4144{ TFormMain }
     
    4952procedure TFormMain.ButtonRunClick(Sender: TObject);
    5053begin
     54  Machine.Reset;
    5155  with TInstructionWriter.Create do
    5256  try
     
    5660    Free;
    5761  end;
    58   Machine.Reset;
    5962  Machine.Cpu.Run;
     63  Label1.Caption := 'Executed instructions: ' + IntToStr(Machine.Cpu.ExecutedCount);
     64end;
     65
     66procedure TFormMain.ButtonMemoryClick(Sender: TObject);
     67begin
     68  FormMemory.Memory := Machine.Memory;
     69  FormMemory.Show;
    6070end;
    6171
  • branches/UltimatOS/Graphics.asm

    r29 r30  
    1 Rectangle: ; R0 - Color, R1 - Width, R2 - Height   
    2   PUSH R3
    3   PUSH R4
    4   PUSH R5   
    5   SET  R3, 0 ; X
    6   SET  R4, 0 ; Screen address
    7   IN   R5, ScreenGetWidth
    8   SHL  R5, 2 ; multiply by 4
     1Rectangle: ; R0 - Color, R1 - X, R2 - Y, R3 - Width, R4 - Height   
     2  PUSH R5 ; loop X
     3  PUSH R6 ; loop Y
     4  PUSH R7 ; color
     5  PUSH R8 ; X
     6  PUSH R9 ; Y
     7  COPY R7, R0
     8  COPY R8, R1
     9  COPY R9, R2
     10  COPY R6, R4
     11  PUSH R0
     12  PUSH R1
    913Start:
    10   OUT  ScreenSetAddr, R4
    11   COPY R3, R1
     14  COPY R0, R8
     15  COPY R1, R9
     16  CALL SetPixelAddr 
     17  COPY R5, R3
    1218Line:
    13   OUT  ScreenWriteData, R0
    14   DEC  R3
    15   JPNZ R3, Line
    16   DEC  R2
    17   ADD  R4, R5
    18   JPNZ R2, Start
    19   POP  R5
    20   POP  R4
     19  OUT  ScreenWriteData, R7
     20  DEC  R5
     21  JPNZ R5, Line
     22  DEC  R6
     23  INC  R9
     24  JPNZ R6, Start
     25  POP  R1
     26  POP  R0
     27  POP  R9
     28  POP  R8
     29  POP  R7
     30  POP  R6
    2131  POP  R3 
    2232  RET
     
    5565  IN   R8, ScreenGetWidth
    5666  SET  R4, CharHeight
    57   SET  R12, 1
     67  SET  R10, $ffffff
     68  SET  R11, 5
     69  SET  R13, 1
    5870WriteCharLoopY:
    5971  COPY R0, R5
     
    7385  DEC  R9
    7486  SHR  R7, 1
    75   JPNZ WriteCharLoopX:
     87  JPNZ R9, WriteCharLoopX
    7688  DEC  R4
    77   ADD  R2, R5
    78   JPNZ WriteCharLoopY:
     89  INC  R6
     90  INC  R3
     91  JPNZ R4, WriteCharLoopY
    7992  POP  R13
    8093  POP  R12
     
    94107  PUSH R4 ; character width
    95108  PUSH R5 ; byte mask
     109  PUSH R6 ; X
     110  PUSH R7 ; Y
     111  PUSH R1
     112  PUSH R2
     113  PUSH R0
     114  COPY R6, R1
     115  COPY R7, R2
     116  COPY R3, R0
    96117  SET  R5, $ff
    97   COPY R3, R0
    98118  SET  R4, CharWidth 
    99119TextOutLoop:
     
    101121  AND  R0, R5
    102122  JPZ  R0, TextOutLoop2
     123  COPY R1, R6
     124  COPY R2, R7
    103125  CALL WriteChar
    104   ADD  R1, R4
     126  ADD  R6, R4
    105127  INC  R3
    106128  JP   TextOutLoop
    107129TextOutLoop2:
     130  POP  R0
     131  POP  R2
     132  POP  R1
     133  POP  R7
     134  POP  R6
     135  POP  R5
    108136  POP  R4
    109137  POP  R3
  • branches/UltimatOS/Program.asm

    r29 r30  
    1313  CALL TextOut
    1414 
     15  ;SET  R0, 110
     16  ;SET  R1, 110
     17  ;CALL SetPixelAddr
     18 
     19  ;SET  R0, 65
     20  ;SET  R1, 110
     21  ;SET  R2, 110
     22  ;CALL WriteChar
     23 
    1524  HALT
    1625 
  • branches/UltimatOS/UCpu.pas

    r29 r30  
    3131    function Pop: Integer;
    3232  public
     33    ExecutedCount: Integer;
    3334    Terminated: Boolean;
    3435    Memory: TMemory;
     
    9394begin
    9495  Instruction := TInstruction(ReadByte);
     96  Inc(ExecutedCount);
    9597  case Instruction of
    9698    inNop: ;
     
    211213  IP := 0;
    212214  SP := 0;
     215  ExecutedCount := 0;
    213216end;
    214217
  • branches/UltimatOS/UMachine.pas

    r29 r30  
    211211  Screen.Reset;
    212212  Cpu.Reset;
     213  FillChar(Memory.Data^, Memory.Size, 0);
    213214end;
    214215
     
    216217begin
    217218  Memory := TMemory.Create;
    218   Memory.Size := 65535;
     219  Memory.Size := 200000;
    219220  Keyboard := TKeyboard.Create;
    220221  Mouse := TMouse.Create;
  • branches/UltimatOS/UltimatOS.lpi

    r29 r30  
    2424          <SearchPaths>
    2525            <IncludeFiles Value="$(ProjOutDir)"/>
     26            <OtherUnitFiles Value="Forms"/>
    2627            <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    2728          </SearchPaths>
     
    7273      </Unit>
    7374      <Unit>
    74         <Filename Value="UFormMain.pas"/>
     75        <Filename Value="Forms/UFormMain.pas"/>
    7576        <IsPartOfProject Value="True"/>
    7677        <ComponentName Value="FormMain"/>
     
    9495        <IsPartOfProject Value="True"/>
    9596      </Unit>
     97      <Unit>
     98        <Filename Value="Forms/UFormMemory.pas"/>
     99        <IsPartOfProject Value="True"/>
     100        <ComponentName Value="FormMemory"/>
     101        <ResourceBaseClass Value="Form"/>
     102      </Unit>
    96103    </Units>
    97104  </ProjectOptions>
     
    103110    <SearchPaths>
    104111      <IncludeFiles Value="$(ProjOutDir)"/>
     112      <OtherUnitFiles Value="Forms"/>
    105113      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    106114    </SearchPaths>
  • branches/UltimatOS/UltimatOS.lpr

    r29 r30  
    1111  {$ENDIF}
    1212  Interfaces, // this includes the LCL widgetset
    13   Forms, UFormMain, UMachine, UCpu, UMemory, UInstructionWriter
     13  Forms, UFormMain, UMachine, UCpu, UMemory, UInstructionWriter, UFormMemory
    1414  { you can add units after this };
    1515
     
    2121  Application.Initialize;
    2222  Application.CreateForm(TFormMain, FormMain);
     23  Application.CreateForm(TFormMemory, FormMemory);
    2324  Application.Run;
    2425end.
Note: See TracChangeset for help on using the changeset viewer.