Changeset 112


Ignore:
Timestamp:
May 17, 2019, 10:06:59 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Redraw output form content only if output instruction was used in interpretter mode.
  • Modified: Redraw memory form content only if memory was written in interpretter mode.
  • Fixed: Replace windows newlines by unix newlines in interpretter output under Linux.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMemory.lfm

    r103 r112  
    88  ClientWidth = 586
    99  DesignTimePPI = 144
    10   LCLVersion = '2.0.0.4'
     10  LCLVersion = '2.0.2.0'
    1111  object Label6: TLabel
    1212    Left = 6
    13     Height = 25
     13    Height = 26
    1414    Top = 6
    1515    Width = 574
     
    2222  object ListViewMemory: TListView
    2323    Left = 6
    24     Height = 345
    25     Top = 37
     24    Height = 344
     25    Top = 38
    2626    Width = 574
    2727    Align = alClient
  • trunk/Forms/UFormMemory.pas

    r78 r112  
    4242  if Core.CurrentTarget is TTargetInterpretter then
    4343  with TTargetInterpretter(Core.CurrentTarget) do begin
    44     ListViewMemory.Items.Count := Ceil(MemoryMaxUsed / RowSize);
    45     ListViewMemory.Refresh;
     44    if MemoryChanged then begin
     45      MemoryChanged := False;
     46      ListViewMemory.Items.Count := Ceil((MemoryMaxUsedAddr + 1) / RowSize);
     47      ListViewMemory.Refresh;
     48    end;
    4649  end;
    4750end;
     
    5457  if Core.CurrentTarget is TTargetInterpretter then
    5558  with TTargetInterpretter(Core.CurrentTarget) do
    56   if (Item.Index >= 0) and (Item.Index <= Trunc(MemoryMaxUsed / RowSize)) then begin
     59  if (Item.Index >= 0) and (Item.Index <= Trunc((MemoryMaxUsedAddr + 1) / RowSize)) then begin
    5760    Item.Caption := IntToHex(Item.Index * RowSize, 8);
    5861    Row := '';
    5962    for I := 0 to RowSize - 1 do
    60       if (Item.Index * RowSize + I) < MemoryMaxUsed then
     63      if (Item.Index * RowSize + I) < (MemoryMaxUsedAddr + 1) then
    6164        Row := Row + ' ' + IntToHex(Memory[Item.Index * RowSize + I], 2);
    6265    Item.SubItems.Add(Row);
  • trunk/Forms/UFormOutput.lfm

    r103 r112  
    11object FormOutput: TFormOutput
    2   Left = 256
    3   Height = 440
    4   Top = 32
    5   Width = 320
     2  Left = 736
     3  Height = 343
     4  Top = 502
     5  Width = 640
    66  Caption = 'Output'
    7   ClientHeight = 440
    8   ClientWidth = 320
     7  ClientHeight = 343
     8  ClientWidth = 640
    99  DesignTimePPI = 144
    10   LCLVersion = '2.0.0.4'
     10  LCLVersion = '2.0.2.0'
    1111  object Label2: TLabel
    1212    Left = 4
    13     Height = 25
     13    Height = 26
    1414    Top = 4
    15     Width = 312
     15    Width = 632
    1616    Align = alTop
    1717    BorderSpacing.Around = 4
     
    2121  object MemoOutput: TMemo
    2222    Left = 4
    23     Height = 403
    24     Top = 33
    25     Width = 312
     23    Height = 305
     24    Top = 34
     25    Width = 632
    2626    Align = alClient
    2727    BorderSpacing.Around = 4
  • trunk/Forms/UFormOutput.pas

    r100 r112  
    3737  if Core.CurrentTarget is TTargetInterpretter then
    3838  with TTargetInterpretter(Core.CurrentTarget) do begin
    39     MemoOutput.Lines.Text := Output;
     39    if OutputChanged then begin
     40      OutputChanged := False;
     41      {$IFDEF LINUX}
     42      MemoOutput.Lines.Text := StringReplace(Output, #10#13, LineEnding, [rfReplaceAll])
     43      {$ELSE}
     44      MemoOutput.Lines.Text := Output;
     45      {$ENDIF}
     46    end;
    4047  end;
    4148end;
  • trunk/Target/UTargetInterpretter.pas

    r96 r112  
    66
    77uses
    8   Classes, SysUtils, Dialogs, Forms, UTarget, UBFTarget;
     8  Classes, SysUtils, Dialogs, Forms, UTarget, UBFTarget, Math;
    99
    1010type
     
    5555    Memory: array of Integer;
    5656    MemoryPosition: Integer;
     57    MemoryChanged: Boolean;
    5758    Output: string;
    5859    OutputPosition: Integer;
     60    OutputChanged: Boolean;
    5961    Input: string;
    6062    InputPosition: Integer;
     
    185187
    186188procedure TTargetInterpretter.CommandInput;
    187 begin
     189var
     190  Addr: Integer;
     191begin
     192  Addr := MemoryPosition + FProgram[FProgramIndex].RelIndex;
    188193  while (InputPosition > Length(Input)) and (FState <> rsStopped) do begin
    189194    Sleep(1);
    190195  end;
    191196  if InputPosition <= Length(Input) then begin
    192     Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] :=
    193       Ord(Input[InputPosition]);
     197    Memory[Addr] := Ord(Input[InputPosition]);
    194198    Inc(InputPosition);
     199    MemoryMaxUsedAddr := Max(Addr, MemoryMaxUsedAddr);
     200    MemoryChanged := True;
    195201  end;
    196202end;
     
    199205begin
    200206  if OutputPosition > Length(Output) then
    201     SetLength(Output, Length(Output) + 1 + Length(Output) div 4);
     207    SetLength(Output, Length(Output) + 1);
    202208  Output[OutputPosition] := Char(Memory[MemoryPosition +
    203209    FProgram[FProgramIndex].RelIndex]);
    204210  Inc(OutputPosition);
     211  OutputChanged := True;
    205212end;
    206213
     
    218225
    219226procedure TTargetInterpretter.CommandInc;
    220 begin
    221   Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] :=
    222     ((Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] +
    223     FProgram[FProgramIndex].Parameter) mod CellSize);
     227var
     228  Addr: Integer;
     229begin
     230  Addr := MemoryPosition + FProgram[FProgramIndex].RelIndex;
     231  Memory[Addr] := ((Memory[Addr] + FProgram[FProgramIndex].Parameter) mod CellSize);
     232  MemoryMaxUsedAddr := Max(Addr, MemoryMaxUsedAddr);
     233  MemoryChanged := True;
    224234end;
    225235
    226236procedure TTargetInterpretter.CommandDec;
    227 begin
    228   Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] :=
    229     ((Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] -
    230     FProgram[FProgramIndex].Parameter) mod CellSize);
     237var
     238  Addr: Integer;
     239begin
     240  Addr := MemoryPosition + FProgram[FProgramIndex].RelIndex;
     241  Memory[Addr] := ((Memory[Addr] - FProgram[FProgramIndex].Parameter) mod CellSize);
     242  MemoryMaxUsedAddr := Max(Addr, MemoryMaxUsedAddr);
     243  MemoryChanged := True;
    231244end;
    232245
     
    235248  if MemoryPosition < MemorySize then Inc(MemoryPosition, FProgram[FProgramIndex].Parameter)
    236249    else raise Exception.Create(SProgramUpperLimit);
    237   if (MemoryPosition + 1) > MemoryMaxUsed then
    238     MemoryMaxUsed := MemoryPosition + 1;
    239250end;
    240251
     
    246257
    247258procedure TTargetInterpretter.CommandSet;
    248 begin
    249   Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] :=
    250     FProgram[FProgramIndex].Parameter mod CellSize;
     259var
     260  Addr: Integer;
     261begin
     262  Addr := MemoryPosition + FProgram[FProgramIndex].RelIndex;
     263  Memory[Addr] := FProgram[FProgramIndex].Parameter mod CellSize;
     264  MemoryMaxUsedAddr := Max(Addr, MemoryMaxUsedAddr);
     265  MemoryChanged := True;
    251266end;
    252267
    253268procedure TTargetInterpretter.CommandMultiply;
    254 begin
    255   Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] :=
    256     (Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] +
    257     Memory[MemoryPosition] * FProgram[FProgramIndex].Parameter) mod CellSize;
     269var
     270  Addr: Integer;
     271begin
     272  Addr := MemoryPosition + FProgram[FProgramIndex].RelIndex;
     273  Memory[Addr] := (Memory[Addr] + Memory[MemoryPosition] *
     274    FProgram[FProgramIndex].Parameter) mod CellSize;
     275  MemoryMaxUsedAddr := Max(Addr, MemoryMaxUsedAddr);
     276  MemoryChanged := True;
    258277end;
    259278
     
    270289  OutputPosition := 1;
    271290  MemoryPosition := 0;
    272   MemoryMaxUsed := 1;
     291  MemoryMaxUsedAddr := 0;
    273292  //FillChar(Pointer(Memory)^, Length(Memory), 0);
    274293  for I := 0 to Length(Memory) - 1 do
    275294    Memory[I] := 0;
     295  MemoryChanged := True;
    276296  FStepCount := 0;
    277297  PrepareBreakPoints;
  • trunk/UBFTarget.pas

    r96 r112  
    4747  public
    4848    MemorySize: Integer;
    49     MemoryMaxUsed: Integer;
     49    MemoryMaxUsedAddr: Integer;
    5050    CellSize: Integer;
    5151    Optimizations: TOptimizations;
Note: See TracChangeset for help on using the changeset viewer.