Changeset 186


Ignore:
Timestamp:
May 1, 2019, 11:39:27 PM (6 years ago)
Author:
chronos
Message:
  • Added: Partial implementation of compiler to Pascal source.
Location:
branches/virtualcpu4
Files:
3 added
5 edited

Legend:

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

    r185 r186  
    11object FormMain: TFormMain
    2   Left = 780
    3   Height = 269
    4   Top = 527
    5   Width = 659
     2  Left = 686
     3  Height = 318
     4  Top = 444
     5  Width = 806
    66  Caption = 'VirtCpu4'
    7   ClientHeight = 269
    8   ClientWidth = 659
     7  ClientHeight = 318
     8  ClientWidth = 806
    99  DesignTimePPI = 144
    1010  OnCreate = FormCreate
     
    4343  end
    4444  object ButtonMemory: TButton
    45     Left = 371
     45    Left = 24
    4646    Height = 38
    47     Top = 64
     47    Top = 112
    4848    Width = 185
    4949    Caption = 'Memory'
     
    5353  end
    5454  object ButtonCpuState: TButton
    55     Left = 371
     55    Left = 24
    5656    Height = 38
    57     Top = 110
     57    Top = 160
    5858    Width = 185
    5959    Caption = 'CPU state'
     
    8585    Left = 371
    8686    Height = 38
    87     Top = 154
     87    Top = 56
    8888    Width = 185
    8989    Caption = 'Assembler'
     
    9393  end
    9494  object ButtonClearMemory: TButton
    95     Left = 371
     95    Left = 24
    9696    Height = 38
    97     Top = 192
     97    Top = 208
    9898    Width = 185
    9999    Caption = 'Clear memory'
     
    102102    TabOrder = 8
    103103  end
     104  object ButtonCompilerPascal: TButton
     105    Left = 371
     106    Height = 38
     107    Top = 200
     108    Width = 185
     109    Caption = 'Pascal compiler'
     110    OnClick = ButtonCompilerPascalClick
     111    ParentFont = False
     112    TabOrder = 9
     113  end
    104114end
  • branches/virtualcpu4/Forms/UFormMain.pas

    r185 r186  
    1515  TFormMain = class(TForm)
    1616    ButtonAssembler: TButton;
     17    ButtonCompilerPascal: TButton;
    1718    ButtonClearMemory: TButton;
    1819    ButtonScreen: TButton;
     
    2526    procedure ButtonAssemblerClick(Sender: TObject);
    2627    procedure ButtonClearMemoryClick(Sender: TObject);
     28    procedure ButtonCompilerPascalClick(Sender: TObject);
    2729    procedure ButtonConsoleClick(Sender: TObject);
    2830    procedure ButtonCpuStateClick(Sender: TObject);
     
    5254uses
    5355  UFormDisassembler, UFormMemory, UFormCpuState, UFormScreen, UFormConsole,
    54   UFormAssembler;
     56  UFormAssembler, UFormCompilerPascal;
    5557
    5658{ TFormMain }
     
    116118begin
    117119  Machine.ClearMemory;
     120end;
     121
     122procedure TFormMain.ButtonCompilerPascalClick(Sender: TObject);
     123begin
     124  if not Assigned(FormCompilerPascal) then
     125    FormCompilerPascal := TFormCompilerPascal.Create(Self);
     126  FormCompilerPascal.CompilerPascal.Reader.Cpu := Machine.Cpu;
     127  FormCompilerPascal.Show;
    118128end;
    119129
  • branches/virtualcpu4/UCpu.pas

    r184 r186  
    275275  case AddrSize of
    276276    bw8: case DataSize of
    277       bw8: Registers[R1].B := PByte(Memory + PByte(@Registers[R2])^)^;
    278       bw16: Registers[R1].W := PWord(Memory + PByte(@Registers[R2])^)^;
    279       bw32: Registers[R1].D := PDWord(Memory + PByte(@Registers[R2])^)^;
    280       bw64: Registers[R1].Q := PQWord(Memory + PByte(@Registers[R2])^)^;
     277      bw8: Registers[R1].B := PByte(Memory + Registers[R2].B)^;
     278      bw16: Registers[R1].W := PWord(Memory + Registers[R2].B)^;
     279      bw32: Registers[R1].D := PDWord(Memory + Registers[R2].B)^;
     280      bw64: Registers[R1].Q := PQWord(Memory + Registers[R2].B)^;
    281281    end;
    282282    bw16: case DataSize of
    283       bw8: Registers[R1].B := PByte(Memory + PWord(@Registers[R2])^)^;
    284       bw16: Registers[R1].W := PWord(Memory + PWord(@Registers[R2])^)^;
    285       bw32: Registers[R1].D := PDWord(Memory + PWord(@Registers[R2])^)^;
    286       bw64: Registers[R1].Q := PQWord(Memory + PWord(@Registers[R2])^)^;
     283      bw8: Registers[R1].B := PByte(Memory + Registers[R2].W)^;
     284      bw16: Registers[R1].W := PWord(Memory + Registers[R2].W)^;
     285      bw32: Registers[R1].D := PDWord(Memory + Registers[R2].W)^;
     286      bw64: Registers[R1].Q := PQWord(Memory + Registers[R2].W)^;
    287287    end;
    288288    bw32: case DataSize of
    289       bw8: Registers[R1].B := PByte(Memory + PDWord(@Registers[R2])^)^;
    290       bw16: Registers[R1].W := PWord(Memory + PDWord(@Registers[R2])^)^;
    291       bw32: Registers[R1].D := PDWord(Memory + PDWord(@Registers[R2])^)^;
    292       bw64: Registers[R1].Q := PQWord(Memory + PDWord(@Registers[R2])^)^;
     289      bw8: Registers[R1].B := PByte(Memory + Registers[R2].D)^;
     290      bw16: Registers[R1].W := PWord(Memory + Registers[R2].D)^;
     291      bw32: Registers[R1].D := PDWord(Memory + Registers[R2].D)^;
     292      bw64: Registers[R1].Q := PQWord(Memory + Registers[R2].D)^;
    293293    end;
    294294    bw64: case DataSize of
    295       bw8: Registers[R1].B := PByte(Memory + PQWord(@Registers[R2])^)^;
    296       bw16: Registers[R1].W := PWord(Memory + PQWord(@Registers[R2])^)^;
    297       bw32: Registers[R1].D := PDWord(Memory + PQWord(@Registers[R2])^)^;
    298       bw64: Registers[R1].Q := PQWord(Memory + PQWord(@Registers[R2])^)^;
     295      bw8: Registers[R1].B := PByte(Memory + Registers[R2].Q)^;
     296      bw16: Registers[R1].W := PWord(Memory + Registers[R2].Q)^;
     297      bw32: Registers[R1].D := PDWord(Memory + Registers[R2].Q)^;
     298      bw64: Registers[R1].Q := PQWord(Memory + Registers[R2].Q)^;
    299299    end;
    300300  end;
     
    309309  case AddrSize of
    310310    bw8: case DataSize of
    311       bw8: PByte(Memory + PByte(@Registers[R1])^)^ := Registers[R2].B;
    312       bw16: PWord(Memory + PByte(@Registers[R1])^)^ := Registers[R2].W;
    313       bw32: PDWord(Memory + PByte(@Registers[R1])^)^ := Registers[R2].D;
    314       bw64: PQWord(Memory + PByte(@Registers[R1])^)^ := Registers[R2].Q;
     311      bw8: PByte(Memory + Registers[R1].B)^ := Registers[R2].B;
     312      bw16: PWord(Memory + Registers[R1].B)^ := Registers[R2].W;
     313      bw32: PDWord(Memory + Registers[R1].B)^ := Registers[R2].D;
     314      bw64: PQWord(Memory + Registers[R1].B)^ := Registers[R2].Q;
    315315    end;
    316316    bw16: case DataSize of
    317       bw8: PByte(Memory + PWord(@Registers[R1])^)^ := Registers[R2].B;
    318       bw16: PWord(Memory + PWord(@Registers[R1])^)^ := Registers[R2].W;
    319       bw32: PDWord(Memory + PWord(@Registers[R1])^)^ := Registers[R2].D;
    320       bw64: PQWord(Memory + PWord(@Registers[R1])^)^ := Registers[R2].Q;
     317      bw8: PByte(Memory + Registers[R1].W)^ := Registers[R2].B;
     318      bw16: PWord(Memory + Registers[R1].W)^ := Registers[R2].W;
     319      bw32: PDWord(Memory + Registers[R1].W)^ := Registers[R2].D;
     320      bw64: PQWord(Memory + Registers[R1].W)^ := Registers[R2].Q;
    321321    end;
    322322    bw32: case DataSize of
    323       bw8: PByte(Memory + PDWord(@Registers[R1])^)^ := Registers[R2].B;
    324       bw16: PWord(Memory + PDWord(@Registers[R1])^)^ := Registers[R2].W;
    325       bw32: PDWord(Memory + PDWord(@Registers[R1])^)^ := Registers[R2].D;
    326       bw64: PQWord(Memory + PDWord(@Registers[R1])^)^ := Registers[R2].Q;
     323      bw8: PByte(Memory + Registers[R1].D)^ := Registers[R2].B;
     324      bw16: PWord(Memory + Registers[R1].D)^ := Registers[R2].W;
     325      bw32: PDWord(Memory + Registers[R1].D)^ := Registers[R2].D;
     326      bw64: PQWord(Memory + Registers[R1].D)^ := Registers[R2].Q;
    327327    end;
    328328    bw64: case DataSize of
    329       bw8: PByte(Memory + PQWord(@Registers[R1])^)^ := Registers[R2].B;
    330       bw16: PWord(Memory + PQWord(@Registers[R1])^)^ := Registers[R2].W;
    331       bw32: PDWord(Memory + PQWord(@Registers[R1])^)^ := Registers[R2].D;
    332       bw64: PQWord(Memory + PQWord(@Registers[R1])^)^ := Registers[R2].Q;
     329      bw8: PByte(Memory + Registers[R1].Q)^ := Registers[R2].B;
     330      bw16: PWord(Memory + Registers[R1].Q)^ := Registers[R2].W;
     331      bw32: PDWord(Memory + Registers[R1].Q)^ := Registers[R2].D;
     332      bw64: PQWord(Memory + Registers[R1].Q)^ := Registers[R2].Q;
    333333    end;
    334334  end;
  • branches/virtualcpu4/virtucpu4.lpi

    r185 r186  
    6666      <Modes Count="0"/>
    6767    </RunParams>
    68     <RequiredPackages Count="1">
     68    <RequiredPackages Count="2">
    6969      <Item1>
     70        <PackageName Value="SynEdit"/>
     71      </Item1>
     72      <Item2>
    7073        <PackageName Value="LCL"/>
    71       </Item1>
     74      </Item2>
    7275    </RequiredPackages>
    73     <Units Count="16">
     76    <Units Count="18">
    7477      <Unit0>
    7578        <Filename Value="virtucpu4.lpr"/>
     
    157160        <ResourceBaseClass Value="Form"/>
    158161      </Unit15>
     162      <Unit16>
     163        <Filename Value="Forms\UFormCompilerPascal.pas"/>
     164        <IsPartOfProject Value="True"/>
     165        <ComponentName Value="FormCompilerPascal"/>
     166        <ResourceBaseClass Value="Form"/>
     167      </Unit16>
     168      <Unit17>
     169        <Filename Value="UCompilerPascal.pas"/>
     170        <IsPartOfProject Value="True"/>
     171      </Unit17>
    159172    </Units>
    160173  </ProjectOptions>
  • branches/virtualcpu4/virtucpu4.lpr

    r184 r186  
    1010  SysUtils, Forms, UFormMain, UCpu, UMachine, UMemory, UFormDisassembler,
    1111  UFormMemory, UFormCpuState, UFormScreen, UFormConsole, UDisassembler,
    12   UAssembler, UInstructionReader, UOpcode, UFormAssembler
     12  UAssembler, UInstructionReader, UOpcode, UFormAssembler, UFormCompilerPascal,
     13  UCompilerPascal
    1314  { you can add units after this };
    1415
Note: See TracChangeset for help on using the changeset viewer.