Changeset 112
- Timestamp:
- May 17, 2019, 10:06:59 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMemory.lfm
r103 r112 8 8 ClientWidth = 586 9 9 DesignTimePPI = 144 10 LCLVersion = '2.0. 0.4'10 LCLVersion = '2.0.2.0' 11 11 object Label6: TLabel 12 12 Left = 6 13 Height = 2 513 Height = 26 14 14 Top = 6 15 15 Width = 574 … … 22 22 object ListViewMemory: TListView 23 23 Left = 6 24 Height = 34 525 Top = 3 724 Height = 344 25 Top = 38 26 26 Width = 574 27 27 Align = alClient -
trunk/Forms/UFormMemory.pas
r78 r112 42 42 if Core.CurrentTarget is TTargetInterpretter then 43 43 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; 46 49 end; 47 50 end; … … 54 57 if Core.CurrentTarget is TTargetInterpretter then 55 58 with TTargetInterpretter(Core.CurrentTarget) do 56 if (Item.Index >= 0) and (Item.Index <= Trunc( MemoryMaxUsed/ RowSize)) then begin59 if (Item.Index >= 0) and (Item.Index <= Trunc((MemoryMaxUsedAddr + 1) / RowSize)) then begin 57 60 Item.Caption := IntToHex(Item.Index * RowSize, 8); 58 61 Row := ''; 59 62 for I := 0 to RowSize - 1 do 60 if (Item.Index * RowSize + I) < MemoryMaxUsedthen63 if (Item.Index * RowSize + I) < (MemoryMaxUsedAddr + 1) then 61 64 Row := Row + ' ' + IntToHex(Memory[Item.Index * RowSize + I], 2); 62 65 Item.SubItems.Add(Row); -
trunk/Forms/UFormOutput.lfm
r103 r112 1 1 object FormOutput: TFormOutput 2 Left = 2563 Height = 4404 Top = 325 Width = 3202 Left = 736 3 Height = 343 4 Top = 502 5 Width = 640 6 6 Caption = 'Output' 7 ClientHeight = 4408 ClientWidth = 3207 ClientHeight = 343 8 ClientWidth = 640 9 9 DesignTimePPI = 144 10 LCLVersion = '2.0. 0.4'10 LCLVersion = '2.0.2.0' 11 11 object Label2: TLabel 12 12 Left = 4 13 Height = 2 513 Height = 26 14 14 Top = 4 15 Width = 31215 Width = 632 16 16 Align = alTop 17 17 BorderSpacing.Around = 4 … … 21 21 object MemoOutput: TMemo 22 22 Left = 4 23 Height = 40324 Top = 3 325 Width = 31223 Height = 305 24 Top = 34 25 Width = 632 26 26 Align = alClient 27 27 BorderSpacing.Around = 4 -
trunk/Forms/UFormOutput.pas
r100 r112 37 37 if Core.CurrentTarget is TTargetInterpretter then 38 38 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; 40 47 end; 41 48 end; -
trunk/Target/UTargetInterpretter.pas
r96 r112 6 6 7 7 uses 8 Classes, SysUtils, Dialogs, Forms, UTarget, UBFTarget ;8 Classes, SysUtils, Dialogs, Forms, UTarget, UBFTarget, Math; 9 9 10 10 type … … 55 55 Memory: array of Integer; 56 56 MemoryPosition: Integer; 57 MemoryChanged: Boolean; 57 58 Output: string; 58 59 OutputPosition: Integer; 60 OutputChanged: Boolean; 59 61 Input: string; 60 62 InputPosition: Integer; … … 185 187 186 188 procedure TTargetInterpretter.CommandInput; 187 begin 189 var 190 Addr: Integer; 191 begin 192 Addr := MemoryPosition + FProgram[FProgramIndex].RelIndex; 188 193 while (InputPosition > Length(Input)) and (FState <> rsStopped) do begin 189 194 Sleep(1); 190 195 end; 191 196 if InputPosition <= Length(Input) then begin 192 Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] := 193 Ord(Input[InputPosition]); 197 Memory[Addr] := Ord(Input[InputPosition]); 194 198 Inc(InputPosition); 199 MemoryMaxUsedAddr := Max(Addr, MemoryMaxUsedAddr); 200 MemoryChanged := True; 195 201 end; 196 202 end; … … 199 205 begin 200 206 if OutputPosition > Length(Output) then 201 SetLength(Output, Length(Output) + 1 + Length(Output) div 4);207 SetLength(Output, Length(Output) + 1); 202 208 Output[OutputPosition] := Char(Memory[MemoryPosition + 203 209 FProgram[FProgramIndex].RelIndex]); 204 210 Inc(OutputPosition); 211 OutputChanged := True; 205 212 end; 206 213 … … 218 225 219 226 procedure TTargetInterpretter.CommandInc; 220 begin 221 Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] := 222 ((Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] + 223 FProgram[FProgramIndex].Parameter) mod CellSize); 227 var 228 Addr: Integer; 229 begin 230 Addr := MemoryPosition + FProgram[FProgramIndex].RelIndex; 231 Memory[Addr] := ((Memory[Addr] + FProgram[FProgramIndex].Parameter) mod CellSize); 232 MemoryMaxUsedAddr := Max(Addr, MemoryMaxUsedAddr); 233 MemoryChanged := True; 224 234 end; 225 235 226 236 procedure TTargetInterpretter.CommandDec; 227 begin 228 Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] := 229 ((Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] - 230 FProgram[FProgramIndex].Parameter) mod CellSize); 237 var 238 Addr: Integer; 239 begin 240 Addr := MemoryPosition + FProgram[FProgramIndex].RelIndex; 241 Memory[Addr] := ((Memory[Addr] - FProgram[FProgramIndex].Parameter) mod CellSize); 242 MemoryMaxUsedAddr := Max(Addr, MemoryMaxUsedAddr); 243 MemoryChanged := True; 231 244 end; 232 245 … … 235 248 if MemoryPosition < MemorySize then Inc(MemoryPosition, FProgram[FProgramIndex].Parameter) 236 249 else raise Exception.Create(SProgramUpperLimit); 237 if (MemoryPosition + 1) > MemoryMaxUsed then238 MemoryMaxUsed := MemoryPosition + 1;239 250 end; 240 251 … … 246 257 247 258 procedure TTargetInterpretter.CommandSet; 248 begin 249 Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] := 250 FProgram[FProgramIndex].Parameter mod CellSize; 259 var 260 Addr: Integer; 261 begin 262 Addr := MemoryPosition + FProgram[FProgramIndex].RelIndex; 263 Memory[Addr] := FProgram[FProgramIndex].Parameter mod CellSize; 264 MemoryMaxUsedAddr := Max(Addr, MemoryMaxUsedAddr); 265 MemoryChanged := True; 251 266 end; 252 267 253 268 procedure TTargetInterpretter.CommandMultiply; 254 begin 255 Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] := 256 (Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] + 257 Memory[MemoryPosition] * FProgram[FProgramIndex].Parameter) mod CellSize; 269 var 270 Addr: Integer; 271 begin 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; 258 277 end; 259 278 … … 270 289 OutputPosition := 1; 271 290 MemoryPosition := 0; 272 MemoryMaxUsed := 1;291 MemoryMaxUsedAddr := 0; 273 292 //FillChar(Pointer(Memory)^, Length(Memory), 0); 274 293 for I := 0 to Length(Memory) - 1 do 275 294 Memory[I] := 0; 295 MemoryChanged := True; 276 296 FStepCount := 0; 277 297 PrepareBreakPoints; -
trunk/UBFTarget.pas
r96 r112 47 47 public 48 48 MemorySize: Integer; 49 MemoryMaxUsed : Integer;49 MemoryMaxUsedAddr: Integer; 50 50 CellSize: Integer; 51 51 Optimizations: TOptimizations;
Note:
See TracChangeset
for help on using the changeset viewer.