Changeset 47 for branches/ByteArray/Devices/Memory.pas
- Timestamp:
- Oct 25, 2023, 12:33:07 AM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ByteArray/Devices/Memory.pas
r46 r47 17 17 public 18 18 Position: Integer; 19 function Read(Address: TBigInt; Size: Byte): TBigInt;20 function ReadPos( Size: Byte): TBigInt;21 procedure Write(Address: TBigInt; Size: Byte; Value: TBigInt);22 procedure WritePos( Size: Byte; Value: TBigInt);19 function Read(Address: TBigInt; ASize: TBigIntSize): TBigInt; 20 function ReadPos(ASize: Byte): TBigInt; 21 procedure Write(Address: TBigInt; ASize: TBigIntSize; Value: TBigInt); 22 procedure WritePos(ASize: Byte; Value: TBigInt); 23 23 procedure WriteStringPos(Value: string); 24 24 function GetAddressCount: Integer; override; … … 30 30 31 31 implementation 32 33 resourcestring 34 SOutOfRange = 'Out of range'; 32 35 33 36 { TMemory } … … 43 46 end; 44 47 45 function TMemory.Read(Address: TBigInt; Size: Byte): TBigInt;48 function TMemory.Read(Address: TBigInt; ASize: TBigIntSize): TBigInt; 46 49 begin 47 case Size of 50 if Address + ASize >= Size then raise Exception.Create(SOutOfRange); 51 case ASize of 48 52 1: Result := PByte(FData + Integer(Address))^; 49 53 2: Result := PWord(FData + Integer(Address))^; … … 53 57 end; 54 58 55 function TMemory.ReadPos( Size: Byte): TBigInt;59 function TMemory.ReadPos(ASize: Byte): TBigInt; 56 60 begin 57 Result := Read(Position, Size);61 Result := Read(Position, ASize); 58 62 end; 59 63 60 procedure TMemory.Write(Address: TBigInt; Size: Byte; Value: TBigInt);64 procedure TMemory.Write(Address: TBigInt; ASize: TBigIntSize; Value: TBigInt); 61 65 begin 62 case Size of 66 if Address + ASize >= Size then raise Exception.Create(SOutOfRange); 67 case ASize of 63 68 1: PByte(FData + Integer(Address))^ := Value; 64 69 2: PWord(FData + Integer(Address))^ := Value; … … 68 73 end; 69 74 70 procedure TMemory.WritePos( Size: Byte; Value: TBigInt);75 procedure TMemory.WritePos(ASize: Byte; Value: TBigInt); 71 76 begin 72 Write(Position, Size, Value);77 Write(Position, ASize, Value); 73 78 end; 74 79
Note:
See TracChangeset
for help on using the changeset viewer.