Ignore:
Timestamp:
Aug 6, 2024, 10:31:16 PM (2 months ago)
Author:
chronos
Message:
  • Modified: Optimized DeviceMapper read/write handlers calls without case statement.
  • Modified: Use TInt as base data type which can be redefined to different higher integer type. For start it is Int64.
Location:
branches/ByteArray
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ByteArray

    • Property svn:ignore set to
      lib
      heaptrclog.trc
      ByteArray
      ByteArray.dbg
      ByteArray.lps
      ByteArray.res
  • branches/ByteArray/Core.pas

    r5 r9  
    4545    procedure DataModuleDestroy(Sender: TObject);
    4646  private
    47     procedure InitMachine;
    4847    procedure LoadConfig;
    4948    procedure SaveConfig;
     
    5958    StartUpForm: string;
    6059    AutoStartMachine: Boolean;
     60    ExecutableFileName: string;
    6161    Machine: TMachine;
    6262  end;
     
    7878begin
    7979  Machine := TMachine.Create;
    80   //InitMachine;
    8180  LoadConfig;
    8281
     
    9493    ADebugger.Execute;
    9594  end;
     95  if FileExists(ExecutableFileName) then
     96    Machine.Memory.LoadFromFile(ExecutableFileName);
    9697  if AutoStartMachine then
    9798    Machine.PowerOn;
     
    213214
    214215  FreeAndNil(Machine);
    215 end;
    216 
    217 procedure TCore.InitMachine;
    218 var
    219   Loop: TBigInt;
    220 begin
    221   with Machine.Cpu do begin
    222     Reset;
    223 
    224     // LD A, 'A'
    225     WriteInstruction(inLoadConst);
    226     WriteRegister(0);
    227     Write(DataWidth, Ord('A'));
    228 
    229     // LD B, 8
    230     WriteInstruction(inLoadConst);
    231     WriteRegister(1);
    232     Write(DataWidth, Machine.Serial.BaseAddress);
    233 
    234     // OUT (B), A
    235     WriteInstruction(inOutput);
    236     WriteRegister(1);
    237     WriteRegister(0);
    238 
    239     // LD B,
    240     WriteInstruction(inLoadConst);
    241     WriteRegister(1);
    242     Write(DataWidth, Machine.FrameBuffer.BaseAddress);
    243 
    244     WriteInstruction(inLoadConst);
    245     WriteRegister(2);
    246     Write(DataWidth, 10);
    247 
    248     Loop := PC;
    249 
    250     WriteInstruction(inOutput);
    251     WriteRegister(1);
    252     WriteRegister(0);
    253 
    254     WriteInstruction(inInc);
    255     WriteRegister(0);
    256 
    257     WriteInstruction(inDec);
    258     WriteRegister(2);
    259 
    260     WriteInstruction(inJumpNotZero);
    261     WriteRegister(2);
    262     Write(AddressWidth, Loop);
    263 
    264     WriteInstruction(inHalt);
    265   end;
    266216end;
    267217
     
    281231    StartUpForm := ReadStringWithDefault('StartUpForm', 'Screen');
    282232    AutoStartMachine := ReadBoolWithDefault('AutoStartMachine', True);
     233    ExecutableFileName := ReadStringWithDefault('ExecutableFileName', 'compiled.bin');
    283234  finally
    284235    Free;
     
    299250    WriteString('StartUpForm', StartUpForm);
    300251    WriteBool('AutoStartMachine', AutoStartMachine);
     252    WriteString('ExecutableFileName', ExecutableFileName);
    301253  finally
    302254    Free;
Note: See TracChangeset for help on using the changeset viewer.