Changeset 86 for trunk/Target/UTargetInterpretter.pas
- Timestamp:
- Aug 29, 2017, 5:12:18 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTargetInterpretter.pas
r80 r86 44 44 procedure CommandLoopEnd; 45 45 procedure CommandSet; 46 procedure CommandMultiply; 46 47 procedure PrepareBreakPoints; 47 48 protected … … 75 76 const 76 77 BrainFuckCommandText: array[TMachineCommand] of Char = ( 77 ' ', '+', '-', '>', '<', '.', ',', '[', ']', '@', '=' );78 ' ', '+', '-', '>', '<', '.', ',', '[', ']', '@', '=', '*'); 78 79 79 80 … … 189 190 end; 190 191 if InputPosition <= Length(Input) then begin 191 Memory[MemoryPosition] := Ord(Input[InputPosition]); 192 Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] := 193 Ord(Input[InputPosition]); 192 194 Inc(InputPosition); 193 195 end; … … 198 200 if OutputPosition > Length(Output) then 199 201 SetLength(Output, Length(Output) + 1 + Length(Output) div 4); 200 Output[OutputPosition] := Char(Memory[MemoryPosition]); 202 Output[OutputPosition] := Char(Memory[MemoryPosition + 203 FProgram[FProgramIndex].RelIndex]); 201 204 Inc(OutputPosition); 202 205 end; … … 204 207 procedure TTargetInterpretter.CommandLoopStart; 205 208 begin 206 if Memory[MemoryPosition ] = 0 then209 if Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] = 0 then 207 210 FProgramIndex := FProgram[FProgramIndex].Parameter; 208 211 end; … … 210 213 procedure TTargetInterpretter.CommandLoopEnd; 211 214 begin 212 if Memory[MemoryPosition ] > 0 then215 if Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] > 0 then 213 216 FProgramIndex := FProgram[FProgramIndex].Parameter - 1; 214 217 end; … … 216 219 procedure TTargetInterpretter.CommandInc; 217 220 begin 218 Memory[MemoryPosition] := ((Memory[MemoryPosition] + FProgram[FProgramIndex].Parameter) mod CellSize); 221 Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] := 222 ((Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] + 223 FProgram[FProgramIndex].Parameter) mod CellSize); 219 224 end; 220 225 221 226 procedure TTargetInterpretter.CommandDec; 222 227 begin 223 Memory[MemoryPosition] := ((Memory[MemoryPosition] - FProgram[FProgramIndex].Parameter) mod CellSize); 228 Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] := 229 ((Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] - 230 FProgram[FProgramIndex].Parameter) mod CellSize); 224 231 end; 225 232 … … 240 247 procedure TTargetInterpretter.CommandSet; 241 248 begin 242 Memory[MemoryPosition] := FProgram[FProgramIndex].Parameter mod CellSize; 249 Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] := 250 FProgram[FProgramIndex].Parameter mod CellSize; 251 end; 252 253 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; 243 258 end; 244 259 … … 411 426 // Extended commands 412 427 FCommandTable[cmSet] := CommandSet; 428 FCommandTable[cmMultipy] := CommandMultiply; 413 429 end; 414 430
Note:
See TracChangeset
for help on using the changeset viewer.