Changeset 86 for trunk/Target/UTargetDelphi.pas
- Timestamp:
- Aug 29, 2017, 5:12:18 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTargetDelphi.pas
r72 r86 14 14 TTargetDelphi = class(TBFTarget) 15 15 private 16 function GetMemoryCell: string; 16 17 public 17 18 constructor Create; override; … … 38 39 end; 39 40 41 function TTargetDelphi.GetMemoryCell: string; 42 begin 43 Result := 'Memory[Pos'; 44 if FProgram[FProgramIndex].RelIndex > 0 then 45 Result := Result + ' + ' + IntToStr(FProgram[FProgramIndex].RelIndex) 46 else if FProgram[FProgramIndex].RelIndex < 0 then 47 Result := Result + ' - ' + IntToStr(Abs(FProgram[FProgramIndex].RelIndex)); 48 Result := Result + ']'; 49 end; 50 40 51 procedure TTargetDelphi.Compile; 41 52 begin … … 60 71 cmPointerInc: AddLine('Inc(Pos, ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 61 72 cmPointerDec: AddLine('Dec(Pos, ' + IntToStr(FProgram[FProgramIndex].Parameter) + ');'); 62 cmInc: AddLine('Memory[Pos] := Memory[Pos] + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 63 cmDec: AddLine('Memory[Pos] := Memory[Pos] - ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 64 cmSet: AddLine('Memory[Pos] := ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 65 cmOutput: AddLine('Write(Chr(Memory[Pos]));'); 66 cmInput: AddLine('Read(ReadChar); Memory[Pos] := Ord(ReadChar);'); 73 cmInc: AddLine(GetMemoryCell + ' := ' + GetMemoryCell + ' + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 74 cmDec: AddLine(GetMemoryCell + ' := ' + GetMemoryCell + ' - ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 75 cmSet: AddLine(GetMemoryCell + ' := ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 76 cmMultipy: AddLine(GetMemoryCell + ' := ' + GetMemoryCell + ' + Memory[Pos] * ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 77 cmOutput: AddLine('Write(Chr(' + GetMemoryCell + '));'); 78 cmInput: AddLine('Read(ReadChar); ' + GetMemoryCell + ' := Ord(ReadChar);'); 67 79 cmLoopStart: begin 68 AddLine('while Memory[Pos]<> 0 do begin');80 AddLine('while ' + GetMemoryCell + ' <> 0 do begin'); 69 81 Inc(Indent); 70 82 end;
Note:
See TracChangeset
for help on using the changeset viewer.