Changeset 46
- Timestamp:
- Oct 23, 2023, 11:34:54 PM (14 months ago)
- Location:
- branches/ByteArray
- Files:
-
- 17 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ByteArray
-
Property svn:ignore
set to
heaptrclog.trc
lib
ByteArray
ByteArray.exe
ByteArray.lps
ByteArray.res
ByteArray.dbg
-
Property svn:ignore
set to
-
branches/ByteArray/BigInt.pas
r45 r46 23 23 class operator Implicit(A: QWord): TBigInt; 24 24 class operator Implicit(A: Int64): TBigInt; 25 class operator Implicit(A: TBigInt): Byte; 26 class operator Implicit(A: TBigInt): ShortInt; 27 class operator Implicit(A: TBigInt): Word; 28 class operator Implicit(A: TBigInt): Integer; 29 class operator Implicit(A: TBigInt): LongWord; 25 class operator Implicit(A: TBigInt): UInt8; // Byte 26 class operator Implicit(A: TBigInt): Int8; // ShortInt 27 class operator Implicit(A: TBigInt): UInt16; // Word 28 class operator Implicit(A: TBigInt): Int16; // SmallInt 29 class operator Implicit(A: TBigInt): UInt32; // LongWord, DWord, Cardinal 30 class operator Implicit(A: TBigInt): Int32; // Int32, LongInt 31 class operator Implicit(A: TBigInt): UInt64; // QWord 32 class operator Implicit(A: TBigInt): Int64; 30 33 class operator Implicit(A: TBigInt): PByte; 31 class operator Implicit(A: TBigInt): QWord;32 class operator Implicit(A: TBigInt): Int64;33 34 class operator Inc(A: TBigInt) : TBigInt; 34 35 class operator Add(A, B: TBigInt): TBigInt; 35 36 class operator Subtract(A, B: TBigInt): TBigInt; 37 class operator Equal(A, B: TBigInt): Boolean; 38 class operator NotEqual(A, B: TBigInt): Boolean; 39 class operator LessThan(A, B: TBigInt): Boolean; 40 class operator LessThanOrEqual(A, B: TBigInt): Boolean; 41 class operator GreaterThan(A, B: TBigInt): Boolean; 42 class operator GreaterThanOrEqual(A, B: TBigInt): Boolean; 36 43 procedure Shrink; 37 44 procedure SetByteArray(AData: TArrayOfByte; ASize: Byte); … … 41 48 end; 42 49 50 function TryStrToBigInt(const S: string; Out I: TBigInt): Boolean; 43 51 44 52 implementation 53 54 function TryStrToBigInt(const S: string; Out I: TBigInt): Boolean; 55 var 56 Value: Int64; 57 begin 58 Result := TryStrToInt64(S, Value); 59 I := Value; 60 end; 45 61 46 62 { TBigInt } … … 102 118 end; 103 119 104 class operator TBigInt.Implicit(A: TBigInt): Byte;120 class operator TBigInt.Implicit(A: TBigInt): UInt8; 105 121 begin 106 122 if A.Size = 1 then Result := A.Data[0] … … 108 124 end; 109 125 110 class operator TBigInt.Implicit(A: TBigInt): ShortInt;126 class operator TBigInt.Implicit(A: TBigInt): Int8; 111 127 begin 112 128 if A.Size = 1 then Result := A.Data[0] … … 114 130 end; 115 131 116 class operator TBigInt.Implicit(A: TBigInt): Word; 117 begin 118 if A.Size = 2 then Result := PWord(@A.Data[0])^ 119 else raise Exception.Create('x'); 120 end; 121 122 class operator TBigInt.Implicit(A: TBigInt): Integer; 132 class operator TBigInt.Implicit(A: TBigInt): UInt16; 133 begin 134 if A.Size = 2 then Result := PUInt16(@A.Data[0])^ 135 else raise Exception.Create('x'); 136 end; 137 138 class operator TBigInt.Implicit(A: TBigInt): Int16; 139 begin 140 if A.Size = 2 then Result := PInt16(@A.Data[0])^ 141 else raise Exception.Create('x'); 142 end; 143 144 class operator TBigInt.Implicit(A: TBigInt): Int32; 123 145 begin 124 146 case A.Size of … … 131 153 end; 132 154 133 class operator TBigInt.Implicit(A: TBigInt): LongWord; 134 begin 135 if A.Size = 4 then Result := PLongWord(@A.Data[0])^ 155 class operator TBigInt.Implicit(A: TBigInt): UInt32; 156 begin 157 if A.Size = 4 then Result := PInt32(@A.Data[0])^ 158 else raise Exception.Create('x'); 159 end; 160 161 class operator TBigInt.Implicit(A: TBigInt): UInt64; 162 begin 163 if A.Size = 8 then Result := PUInt64(@A.Data[0])^ 164 else raise Exception.Create('x'); 165 end; 166 167 class operator TBigInt.Implicit(A: TBigInt): Int64; 168 begin 169 if A.Size = 8 then Result := PInt64(@A.Data[0])^ 136 170 else raise Exception.Create('x'); 137 171 end; … … 140 174 begin 141 175 if A.Size = 4 then Result := PByte(@PInteger(@A.Data[0])^) 142 else raise Exception.Create('x');143 end;144 145 class operator TBigInt.Implicit(A: TBigInt): QWord;146 begin147 if A.Size = 8 then Result := PQWord(@A.Data[0])^148 else raise Exception.Create('x');149 end;150 151 class operator TBigInt.Implicit(A: TBigInt): Int64;152 begin153 if A.Size = 8 then Result := PInt64(@A.Data[0])^154 176 else raise Exception.Create('x'); 155 177 end; … … 198 220 end; 199 221 222 class operator TBigInt.Equal(A, B: TBigInt): Boolean; 223 begin 224 225 end; 226 227 class operator TBigInt.NotEqual(A, B: TBigInt): Boolean; 228 begin 229 230 end; 231 232 class operator TBigInt.LessThan(A, B: TBigInt): Boolean; 233 begin 234 235 end; 236 237 class operator TBigInt.LessThanOrEqual(A, B: TBigInt): Boolean; 238 begin 239 240 end; 241 242 class operator TBigInt.GreaterThan(A, B: TBigInt): Boolean; 243 begin 244 245 end; 246 247 class operator TBigInt.GreaterThanOrEqual(A, B: TBigInt): Boolean; 248 begin 249 250 end; 251 200 252 procedure TBigInt.Shrink; 201 253 var -
branches/ByteArray/ByteArray.lpi
r45 r46 26 26 <RequiredPackages> 27 27 <Item> 28 <PackageName Value="SynEdit"/> 29 </Item> 30 <Item> 28 31 <PackageName Value="LCL"/> 29 32 </Item> … … 102 105 <Filename Value="Devices/Mouse.pas"/> 103 106 <IsPartOfProject Value="True"/> 107 </Unit> 108 <Unit> 109 <Filename Value="Disassembler.pas"/> 110 <IsPartOfProject Value="True"/> 111 </Unit> 112 <Unit> 113 <Filename Value="Instructions.pas"/> 114 <IsPartOfProject Value="True"/> 115 </Unit> 116 <Unit> 117 <Filename Value="Parser.pas"/> 118 <IsPartOfProject Value="True"/> 119 </Unit> 120 <Unit> 121 <Filename Value="Forms/FormDisassembler.pas"/> 122 <IsPartOfProject Value="True"/> 123 <ComponentName Value="FormDisassembler"/> 124 <HasResources Value="True"/> 125 <ResourceBaseClass Value="Form"/> 126 </Unit> 127 <Unit> 128 <Filename Value="Forms/FormAssembler.pas"/> 129 <IsPartOfProject Value="True"/> 130 <ComponentName Value="FormAssembler"/> 131 <HasResources Value="True"/> 132 <ResourceBaseClass Value="Form"/> 133 </Unit> 134 <Unit> 135 <Filename Value="Forms/FormSourceEditor.pas"/> 136 <IsPartOfProject Value="True"/> 137 <ComponentName Value="FormSourceEditor"/> 138 <HasResources Value="True"/> 139 <ResourceBaseClass Value="Form"/> 140 </Unit> 141 <Unit> 142 <Filename Value="Forms/FormMessages.pas"/> 143 <IsPartOfProject Value="True"/> 144 <ComponentName Value="FormMessages"/> 145 <ResourceBaseClass Value="Form"/> 146 </Unit> 147 <Unit> 148 <Filename Value="Message.pas"/> 149 <IsPartOfProject Value="True"/> 150 </Unit> 151 <Unit> 152 <Filename Value="Assembler.pas"/> 153 <IsPartOfProject Value="True"/> 154 </Unit> 155 <Unit> 156 <Filename Value="Common.pas"/> 157 <IsPartOfProject Value="True"/> 158 </Unit> 159 <Unit> 160 <Filename Value="Forms/FormMemory.pas"/> 161 <IsPartOfProject Value="True"/> 162 <ComponentName Value="FormMemory"/> 163 <HasResources Value="True"/> 164 <ResourceBaseClass Value="Form"/> 104 165 </Unit> 105 166 </Units> -
branches/ByteArray/ByteArray.lpr
r45 r46 11 11 {$ENDIF} 12 12 Interfaces, SysUtils,// this includes the LCL widgetset 13 Forms, FormMain, FormConsole, FormDevice, FormScreen, Cpu, BigInt, Channel, 14 Memory, FrameBuffer, Device, Storage, DeviceMapper, Machine, Serial, Mouse 13 Forms, FormMain, FormConsole, FormDevice, FormScreen, FormDisassembler, 14 FormAssembler, Cpu, BigInt, Channel, Memory, FrameBuffer, Device, Storage, 15 DeviceMapper, Machine, Disassembler, Instructions, Parser, Message, Assembler, 16 Serial, Mouse, FormSourceEditor, FormMessages, FormMemory, Common 15 17 { you can add units after this }; 16 18 -
branches/ByteArray/Cpu.pas
r45 r46 22 22 inJump, inJumpSize, 23 23 inJumpNotZero, inJumpNotZeroSize, 24 inJumpZero, inJumpZeroSize, 24 25 inJumpRel, inJumpRelSize, 25 26 inCall, inCallSize, … … 36 37 inOtir, inOti, inOtdr, inOtd, 37 38 inCpir, inCpi, inCpdr, inCpd, 38 inEx, 39 inC p);39 inEx, inEnableInterrupts, inDisableInterrupts, 40 inCompare); 40 41 41 42 TRegIndex = (riA, riB, riC, riD, riE, riF, riG, riH); … … 64 65 procedure InstructionJumpNotZero; 65 66 procedure InstructionJumpNotZeroSize; 67 procedure InstructionJumpZero; 68 procedure InstructionJumpZeroSize; 66 69 procedure InstructionJumpRel; 67 70 procedure InstructionJumpRelSize; … … 257 260 end; 258 261 262 procedure TCpu.InstructionJumpZero; 263 var 264 RegIndex: TRegIndex; 265 Address: TBigInt; 266 begin 267 RegIndex := ReadRegIndex; 268 Address := Read(AddressWidth); 269 if Byte(Regs[RegIndex]) = 0 then 270 PC := Address; 271 end; 272 273 procedure TCpu.InstructionJumpZeroSize; 274 var 275 RegIndex: TRegIndex; 276 Address: TBigInt; 277 DataSize: Byte; 278 AddressSize: Byte; 279 begin 280 DataSize := Read(1); 281 AddressSize := Read(1); 282 RegIndex := ReadRegIndex; 283 Address := Read(AddressSize); 284 if Int64(Regs[RegIndex].Copy(DataSize)) = 0 then 285 PC := Address; 286 end; 287 259 288 procedure TCpu.InstructionJumpRel; 260 289 begin … … 430 459 Instructions[inJumpNotZero] := InstructionJumpNotZero; 431 460 Instructions[inJumpNotZeroSize] := InstructionJumpNotZeroSize; 461 Instructions[inJumpZero] := InstructionJumpZero; 462 Instructions[inJumpZeroSize] := InstructionJumpZeroSize; 432 463 Instructions[inJumpRel] := InstructionJumpRel; 433 464 Instructions[inJumpRelSize] := InstructionJumpRelSize; -
branches/ByteArray/Devices/Memory.pas
r45 r46 16 16 procedure SetSize(AValue: Integer); 17 17 public 18 Position: Integer; 18 19 function Read(Address: TBigInt; Size: Byte): TBigInt; 20 function ReadPos(Size: Byte): TBigInt; 19 21 procedure Write(Address: TBigInt; Size: Byte; Value: TBigInt); 22 procedure WritePos(Size: Byte; Value: TBigInt); 23 procedure WriteStringPos(Value: string); 20 24 function GetAddressCount: Integer; override; 21 25 procedure SetChannel(Channel: TChannel); override; … … 49 53 end; 50 54 55 function TMemory.ReadPos(Size: Byte): TBigInt; 56 begin 57 Result := Read(Position, Size); 58 end; 59 51 60 procedure TMemory.Write(Address: TBigInt; Size: Byte; Value: TBigInt); 52 61 begin … … 56 65 4: PDWord(FData + Integer(Address))^ := Value; 57 66 8: PQWord(FData + Integer(Address))^ := Value; 67 end; 68 end; 69 70 procedure TMemory.WritePos(Size: Byte; Value: TBigInt); 71 begin 72 Write(Position, Size, Value); 73 end; 74 75 procedure TMemory.WriteStringPos(Value: string); 76 var 77 I: Integer; 78 begin 79 if Length(Value) > 0 then begin 80 if Position + Length(Value) > Size then Size := Position + Length(Value); 81 for I := 0 to Length(Value) - 1 do 82 Write(Position + I, 1, Ord(Value[I + 1])); 83 Inc(Position, Length(Value)); 58 84 end; 59 85 end; -
branches/ByteArray/Forms/FormMain.lfm
r45 r46 14 14 Left = 331 15 15 Top = 79 16 object MenuItem4: TMenuItem 17 Caption = 'File' 18 object MenuItem6: TMenuItem 19 Action = AExit 20 end 21 end 16 22 object MenuItem1: TMenuItem 17 23 Caption = 'View' … … 27 33 Caption = 'Storage' 28 34 end 35 object MenuItem7: TMenuItem 36 Action = AMemory 37 end 38 end 39 object MenuItem2: TMenuItem 40 Caption = 'Tools' 41 object MenuItem3: TMenuItem 42 Action = ASourceEditor 43 end 44 object MenuItem5: TMenuItem 45 Action = ADebugger 46 end 47 end 48 end 49 object ActionList1: TActionList 50 Left = 448 51 Top = 80 52 object ASourceEditor: TAction 53 Caption = 'Source editor' 54 OnExecute = ASourceEditorExecute 55 end 56 object ADebugger: TAction 57 Caption = 'Debugger' 58 OnExecute = ADebuggerExecute 59 end 60 object ADevices: TAction 61 Caption = 'Devices' 62 end 63 object AExit: TAction 64 Caption = 'Exit' 65 OnExecute = AExitExecute 66 end 67 object AMemory: TAction 68 Caption = 'Memory' 69 OnExecute = AMemoryExecute 29 70 end 30 71 end -
branches/ByteArray/Forms/FormMain.pas
r45 r46 4 4 5 5 uses 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, FormConsole,7 Form Screen, Machine;6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ActnList, 7 FormConsole, FormScreen, Machine, FormSourceEditor, FormMemory; 8 8 9 9 type … … 12 12 13 13 TFormMain = class(TForm) 14 AMemory: TAction; 15 AExit: TAction; 16 ADevices: TAction; 17 ADebugger: TAction; 18 ASourceEditor: TAction; 19 ActionList1: TActionList; 14 20 MainMenu1: TMainMenu; 15 21 MenuItem1: TMenuItem; 22 MenuItem2: TMenuItem; 23 MenuItem3: TMenuItem; 24 MenuItem4: TMenuItem; 25 MenuItem5: TMenuItem; 26 MenuItem6: TMenuItem; 27 MenuItem7: TMenuItem; 16 28 MenuItemViewScreen: TMenuItem; 17 29 MenuItemViewStorage: TMenuItem; 18 30 MenuItemViewConsole: TMenuItem; 31 procedure ADebuggerExecute(Sender: TObject); 32 procedure AExitExecute(Sender: TObject); 33 procedure AMemoryExecute(Sender: TObject); 34 procedure ASourceEditorExecute(Sender: TObject); 19 35 procedure FormCreate(Sender: TObject); 20 36 procedure FormDestroy(Sender: TObject); … … 25 41 FormScreen: TFormScreen; 26 42 FormConsole: TFormConsole; 43 FormMemory: TFormMemory; 44 FormSourceEditor: TFormSourceEditor; 27 45 Machine: TMachine; 28 46 procedure InitMachine; 29 47 public 30 procedure DockForm(Form: TForm; DockSite: TWinControl);31 48 end; 32 49 … … 40 57 41 58 uses 42 Cpu, BigInt ;59 Cpu, BigInt, Common; 43 60 44 61 { TFormMain } … … 61 78 end; 62 79 80 procedure TFormMain.AExitExecute(Sender: TObject); 81 begin 82 Close; 83 end; 84 85 procedure TFormMain.AMemoryExecute(Sender: TObject); 86 begin 87 if not Assigned(FormMemory) then begin 88 FormMemory := TFormMemory.Create(nil); 89 FormMemory.Memory := Machine.Memory; 90 end; 91 FormMemory.Show; 92 end; 93 94 procedure TFormMain.ADebuggerExecute(Sender: TObject); 95 begin 96 97 end; 98 99 procedure TFormMain.ASourceEditorExecute(Sender: TObject); 100 begin 101 if not Assigned(FormSourceEditor) then begin 102 FormSourceEditor := TFormSourceEditor.Create(nil); 103 end; 104 FormSourceEditor.Show; 105 end; 106 63 107 procedure TFormMain.FormDestroy(Sender: TObject); 64 108 begin 65 FreeAndNil(FormScreen); 66 FreeAndNil(FormConsole); 109 if Assigned(FormSourceEditor) then FreeAndNil(FormSourceEditor); 110 if Assigned(FormScreen) then FreeAndNil(FormScreen); 111 if Assigned(FormConsole) then FreeAndNil(FormConsole); 112 if Assigned(FormMemory) then FreeAndNil(FormMemory); 67 113 FreeAndNil(Machine); 68 114 end; … … 125 171 end; 126 172 127 procedure TFormMain.DockForm(Form: TForm; DockSite: TWinControl);128 begin129 Form.ManualDock(DockSite, nil, alClient);130 Form.Align := alClient;131 Form.Show;132 end;133 134 173 end. 135 174
Note:
See TracChangeset
for help on using the changeset viewer.