Ignore:
Timestamp:
Nov 25, 2023, 11:47:52 PM (12 months ago)
Author:
chronos
Message:
  • Fixed: Assembler and disassembler to work correctly with supported instructions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ByteArray/Devices/Memory.pas

    r56 r59  
    1616    function GetSize: Integer;
    1717    procedure SetSize(AValue: Integer);
     18    procedure CheckGrow(Address: Integer);
    1819  public
    1920    Position: Integer;
     21    Grow: Boolean;
    2022    procedure Assign(Source: TMemory);
    2123    function Read(Address: TBigInt; ASize: TBigIntSize): TBigInt;
     
    2830    procedure SetChannel(Channel: TChannel); override;
    2931    procedure SaveToFile(FileName: string);
    30     procedure Clean;
     32    procedure FillZero;
     33    procedure Clear;
    3134    property Size: Integer read FSize write SetSize;
    3235    destructor Destroy; override;
     
    5053  FSize := AValue;
    5154  FData := ReAllocMem(FData, AValue);
     55end;
     56
     57procedure TMemory.CheckGrow(Address: Integer);
     58begin
     59  if Grow and (Size < Address) then Size := Address;
    5260end;
    5361
     
    9098procedure TMemory.WritePos(ASize: Byte; Value: TBigInt);
    9199begin
     100  CheckGrow(Position + ASize);
    92101  Write(Position, ASize, Value);
    93102  Inc(Position, ASize);
     
    98107  I: Integer;
    99108begin
     109  CheckGrow(Position + Length(Value));
    100110  if Length(Value) > 0 then begin
    101111    if Position + Length(Value) > FSize then Size := Position + Length(Value);
     
    108118procedure TMemory.WriteMemoryPos(Memory: TMemory);
    109119begin
     120  CheckGrow(Position + Memory.Size);
    110121  if Memory.Size > 0 then begin
    111122    if Position + Memory.Size > FSize then Size := Position + Memory.Size;
     
    126137end;
    127138
    128 procedure TMemory.Clean;
     139procedure TMemory.FillZero;
    129140begin
    130141  FillChar(FData^, FSize, 0);
     142end;
     143
     144procedure TMemory.Clear;
     145begin
     146  Size := 0;
     147  Position := 0;
    131148end;
    132149
Note: See TracChangeset for help on using the changeset viewer.