Changeset 64 for trunk/Target/UTargetC.pas
- Timestamp:
- Dec 4, 2014, 2:59:28 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTargetC.pas
r60 r64 65 65 FProgramIndex := 0; 66 66 while (FProgramIndex < Length(FProgram)) do begin 67 case FProgram[FProgramIndex] of 68 cmPointerInc: begin 69 Sum := CheckOccurence(cmPointerInc); 70 AddLine('Pos = Pos + ' + IntToStr(Sum) + ';'); 71 end; 72 cmPointerDec: begin 73 Sum := CheckOccurence(cmPointerDec); 74 AddLine('Pos = Pos - ' + IntToStr(Sum) + ';'); 75 end; 76 cmInc: begin 77 Sum := CheckOccurence(cmInc); 78 AddLine('Memory[Pos] = Memory[Pos] + ' + IntToStr(Sum) + ';'); 79 end; 80 cmDec: begin 81 Sum := CheckOccurence(cmDec); 82 AddLine('Memory[Pos] = Memory[Pos] - ' + IntToStr(Sum) + ';'); 83 end; 67 case FProgram[FProgramIndex].Command of 68 cmPointerInc: AddLine('Pos = Pos + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 69 cmPointerDec: AddLine('Pos = Pos - ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 70 cmInc: AddLine('Memory[Pos] = Memory[Pos] + ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 71 cmDec: AddLine('Memory[Pos] = Memory[Pos] - ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 84 72 cmOutput: AddLine('putchar(Memory[Pos]);'); 85 73 cmInput: AddLine('Memory[Pos] = getchar();'); 74 cmSet: AddLine('Memory[Pos] = ' + IntToStr(FProgram[FProgramIndex].Parameter) + ';'); 86 75 cmLoopStart: begin 87 if CheckClear then begin 88 AddLine('Memory[Pos] = 0;'); 89 Inc(FProgramIndex, 2); 90 end else begin 91 AddLine('while(Memory[Pos] != 0)'); 92 AddLine('{'); 93 Inc(Indent); 94 end; 76 AddLine('while(Memory[Pos] != 0)'); 77 AddLine('{'); 78 Inc(Indent); 95 79 end; 96 80 cmLoopEnd: begin
Note:
See TracChangeset
for help on using the changeset viewer.