Changeset 165 for branches/virtcpu fixed int
- Timestamp:
- Aug 9, 2018, 9:45:07 AM (6 years ago)
- Location:
- branches/virtcpu fixed int
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/virtcpu fixed int
- Property svn:ignore
-
old new 3 3 virtcpu.lps 4 4 virtcpu.res 5 *.dbg
-
- Property svn:ignore
-
branches/virtcpu fixed int/UFormMain.pas
r163 r165 72 72 AddOut(0, 1); 73 73 AddInc(2); 74 AddJ r(LabelStart);74 AddJump(LabelStart); 75 75 AddHalt; 76 76 end; … … 154 154 function TForm1.CpuInput(Port: T): T; 155 155 begin 156 Result := 0; 156 157 case Port of 157 158 0: begin … … 162 163 if Length(KeyInputBuffer) > 0 then begin 163 164 Result := Ord(KeyInputBuffer[0]); 164 Move(KeyInputBuffer[1], KeyInputBuffer[0], Length(KeyInputBuffer) - 1); 165 if Length(KeyInputBuffer) > 1 then 166 Move(KeyInputBuffer[1], KeyInputBuffer[0], Length(KeyInputBuffer) - 1); 165 167 SetLength(KeyInputBuffer, Length(KeyInputBuffer) - 1); 166 168 end else Result := 0; -
branches/virtcpu fixed int/UInstructionWriter.pas
r163 r165 26 26 procedure AddIn(R1, R2: Integer); 27 27 procedure AddOut(R1, R2: Integer); 28 procedure AddJr(Addr: Integer); 28 procedure AddJump(Addr: Integer); 29 {$IFDEF EXT_REL_JUMP}procedure AddJr(Addr: Integer);{$ENDIF} 29 30 procedure AddInc(R: Integer); 30 31 constructor Create; … … 94 95 end; 95 96 97 procedure TInstructionWriter.AddJump(Addr: Integer); 98 begin 99 Write(T(opJump)); 100 Write(Addr); 101 end; 102 103 {$IFDEF EXT_REL_JUMP} 96 104 procedure TInstructionWriter.AddJr(Addr: Integer); 97 105 begin … … 99 107 Write(Addr - IP - 1); 100 108 end; 109 {$ENDIF} 101 110 102 111 procedure TInstructionWriter.AddInc(R: Integer); -
branches/virtcpu fixed int/UMachine.pas
r164 r165 5 5 {$DEFINE EXT_ARITHMETIC} 6 6 {$DEFINE EXT_CONDITIONAL} 7 //{$DEFINE EXT_LOGICAL}7 {$DEFINE EXT_LOGICAL} 8 8 {$DEFINE EXT_STACK} 9 9 {$DEFINE EXT_SUBROUTINE} 10 //{$DEFINE EXT_SHIFT}10 {$DEFINE EXT_SHIFT} 11 11 //{$DEFINE EXT_BLOCK} 12 12 {$DEFINE EXT_GENERAL} 13 13 //{$DEFINE EXT_BIT} 14 //{$DEFINE EXT_REL_JUMP} 14 15 15 16 // Extension dependencies … … 30 31 31 32 TOpcode = (opNop, opLoad, opHalt, opLoadConst, opLoadMem, opStoreMem, opNeg, 32 opJump, opJumpRel, opCall, opCallRel, opRet, opInput, 33 opOutput, opInc, opDec, opAdd, opSub, opExchg, 34 {$IFDEF EXT_STACK} 35 opPush, opPop, 36 {$ENDIF} 33 opJump, {$IFDEF EXT_REL_JUMP}opJumpRel,{$ENDIF} 34 opInc, opDec, 35 {$IFDEF EXT_ARITHMETIC}opAdd, opSub,{$ENDIF} 36 {$IFDEF EXT_IO}opInput, opOutput,{$ENDIF} 37 {$IFDEF EXT_SUBROUTINE}opCall, 38 {$IFDEF EXT_REL_JUMP}opCallRel,{$ENDIF} 39 opRet,{$ENDIF} 40 {$IFDEF EXT_GENERAL}opExchg,{$ENDIF} 41 {$IFDEF EXT_LOGICAL}opAnd, opOr, opXor,{$ENDIF} 42 {$IFDEF EXT_SHIFT}opShl, opShr,{$ENDIF} 43 {$IFDEF EXT_STACK}opPush, opPop,{$ENDIF} 37 44 {$IFDEF EXT_CONDITIONAL} 38 45 opJumpRelCond, opJumpCond, opTestEqual, opTestNotEqual, opTestLess, … … 53 60 OpcodeHandlers: array[TOpcode] of TOpcodeHandler; 54 61 function ReadNext: T; inline; 62 procedure OpcodeNop; 55 63 procedure OpcodeHalt; 56 procedure OpcodeNop;57 64 procedure OpcodeLoad; 58 65 procedure OpcodeLoadConst; 66 procedure OpcodeJump; 67 procedure OpcodeJumpRel; 68 procedure OpcodeNeg; 69 procedure OpcodeInc; 70 procedure OpcodeDec; 59 71 {$IFDEF EXT_MEMORY} 60 72 procedure OpcodeLoadMem; 61 73 procedure OpcodeStoreMem; 62 74 {$ENDIF} 63 procedure OpcodeNeg;64 75 {$IFDEF EXT_GENERAL} 65 76 procedure OpcodeExchange; 66 77 {$ENDIF} 67 procedure OpcodeJump;68 procedure OpcodeJumpRel;69 78 {$IFDEF EXT_CONDITIONAL} 70 79 procedure OpcodeTestEqual; … … 75 84 procedure OpcodeTestLess; 76 85 procedure OpcodeJumpCond; 86 {$IFDEF EXT_REL_JUMP} 77 87 procedure OpcodeJumpRelCond; 88 {$ENDIF} 89 {$ENDIF} 90 {$IFDEF EXT_SHIFT} 91 procedure OpcodeShl; 92 procedure OpcodeShr; 93 {$ENDIF} 94 {$IFDEF EXT_LOGICAL} 95 procedure OpcodeAnd; 96 procedure OpcodeOr; 97 procedure OpcodeXor; 78 98 {$ENDIF} 79 99 {$IFDEF EXT_STACK} … … 83 103 {$IFDEF EXT_SUBROUTINE} 84 104 procedure OpcodeCall; 105 {$IFDEF EXT_REL_JUMP} 85 106 procedure OpcodeCallRel; 107 {$ENDIF} 86 108 procedure OpcodeReturn; 87 109 {$ENDIF} … … 90 112 procedure OpcodeInput; 91 113 {$ENDIF} 92 procedure OpcodeInc;93 procedure OpcodeDec;94 114 {$IFDEF EXT_ARITHMETIC} 95 115 procedure OpcodeAdd; … … 245 265 end; 246 266 267 {$IFDEF EXT_REL_JUMP} 247 268 procedure TCPU.OpcodeJumpRelCond; 248 269 begin 249 270 if Condition then IP := IP + ReadNext; 271 end; 272 {$ENDIF} 273 {$ENDIF} 274 275 {$IFDEF EXT_SHIFT} 276 procedure TCPU.OpcodeShl; 277 var 278 P1, P2: T; 279 begin 280 P1 := ReadNext; 281 P2 := ReadNext; 282 Registers[P1] := Registers[P1] shl Registers[P2]; 283 end; 284 285 procedure TCPU.OpcodeShr; 286 var 287 P1, P2: T; 288 begin 289 P1 := ReadNext; 290 P2 := ReadNext; 291 Registers[P1] := Registers[P1] shr Registers[P2]; 292 end; 293 {$ENDIF} 294 295 {$IFDEF EXT_LOGICAL} 296 procedure TCPU.OpcodeAnd; 297 var 298 P1, P2: T; 299 begin 300 P1 := ReadNext; 301 P2 := ReadNext; 302 Registers[P1] := Registers[P1] and Registers[P2]; 303 end; 304 305 procedure TCPU.OpcodeOr; 306 var 307 P1, P2: T; 308 begin 309 P1 := ReadNext; 310 P2 := ReadNext; 311 Registers[P1] := Registers[P1] or Registers[P2]; 312 end; 313 314 procedure TCPU.OpcodeXor; 315 var 316 P1, P2: T; 317 begin 318 P1 := ReadNext; 319 P2 := ReadNext; 320 Registers[P1] := Registers[P1] xor Registers[P2]; 250 321 end; 251 322 {$ENDIF} … … 276 347 end; 277 348 349 {$IFDEF EXT_REL_JUMP} 278 350 procedure TCPU.OpcodeCallRel; 279 351 var … … 285 357 IP := IP + Addr; 286 358 end; 359 {$ENDIF} 287 360 288 361 procedure TCPU.OpcodeReturn; … … 386 459 OpcodeHandlers[opHalt] := OpcodeHalt; 387 460 OpcodeHandlers[opLoadConst] := OpcodeLoadConst; 461 OpcodeHandlers[opNeg] := OpcodeNeg; 462 OpcodeHandlers[opJump] := OpcodeJump; 463 {$IFDEF EXT_REL_JUMP} 464 OpcodeHandlers[opJumpRel] := OpcodeJumpRel; 465 {$ENDIF} 388 466 {$IFDEF EXT_MEMORY} 389 467 OpcodeHandlers[opLoadMem] := OpcodeLoadMem; 390 468 OpcodeHandlers[opStoreMem] := OpcodeStoreMem; 391 469 {$ENDIF} 392 OpcodeHandlers[opNeg] := OpcodeNeg;393 OpcodeHandlers[opJump] := OpcodeJump;394 OpcodeHandlers[opJumpRel] := OpcodeJumpRel;395 470 {$IFDEF EXT_GENERAL} 396 471 OpcodeHandlers[opExchg] := OpcodeExchange; 472 {$ENDIF} 473 {$IFDEF EXT_LOGICAL} 474 OpcodeHandlers[opAnd] := OpcodeAnd; 475 OpcodeHandlers[opOr] := OpcodeOr; 476 OpcodeHandlers[opXor] := OpcodeXor; 477 {$ENDIF} 478 {$IFDEF EXT_SHIFT} 479 OpcodeHandlers[opShl] := OpcodeShl; 480 OpcodeHandlers[opShr] := OpcodeShr; 397 481 {$ENDIF} 398 482 {$IFDEF EXT_STACK} … … 402 486 {$IFDEF EXT_SUBROUTINE} 403 487 OpcodeHandlers[opCall] := OpcodeCall; 488 {$IFDEF EXT_REL_JUMP} 404 489 OpcodeHandlers[opCallRel] := OpcodeCallRel; 490 {$ENDIF} 405 491 OpcodeHandlers[opRet] := OpcodeReturn; 406 492 {$ENDIF} … … 417 503 {$IFDEF EXT_ARITHMETIC} 418 504 OpcodeHandlers[opJumpCond] := OpcodeJumpCond; 505 {$IFDEF EXT_REL_JUMP} 419 506 OpcodeHandlers[opJumpRelCond] := OpcodeJumpRelCond; 507 {$ENDIF} 420 508 OpcodeHandlers[opTestEqual] := OpcodeTestEqual; 421 509 OpcodeHandlers[opTestNotEqual] := OpcodeTestNotEqual; -
branches/virtcpu fixed int/virtcpu.lpi
r163 r165 12 12 <Icon Value="0"/> 13 13 </General> 14 <BuildModes Count="1"> 15 <Item1 Name="Default" Default="True"/> 14 <BuildModes Count="2"> 15 <Item1 Name="Debug" Default="True"/> 16 <Item2 Name="Release"> 17 <CompilerOptions> 18 <Version Value="11"/> 19 <PathDelim Value="\"/> 20 <Target> 21 <Filename Value="virtcpu"/> 22 </Target> 23 <SearchPaths> 24 <IncludeFiles Value="$(ProjOutDir)"/> 25 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 26 </SearchPaths> 27 <Parsing> 28 <SyntaxOptions> 29 <SyntaxMode Value="Delphi"/> 30 <CStyleOperator Value="False"/> 31 <AllowLabel Value="False"/> 32 <CPPInline Value="False"/> 33 </SyntaxOptions> 34 </Parsing> 35 <CodeGeneration> 36 <SmartLinkUnit Value="True"/> 37 <Optimizations> 38 <OptimizationLevel Value="3"/> 39 </Optimizations> 40 </CodeGeneration> 41 <Linking> 42 <Debugging> 43 <GenerateDebugInfo Value="False"/> 44 </Debugging> 45 <LinkSmart Value="True"/> 46 <Options> 47 <Win32> 48 <GraphicApplication Value="True"/> 49 </Win32> 50 </Options> 51 </Linking> 52 </CompilerOptions> 53 </Item2> 16 54 </BuildModes> 17 55 <PublishOptions> … … 60 98 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 61 99 </SearchPaths> 100 <Parsing> 101 <SyntaxOptions> 102 <SyntaxMode Value="Delphi"/> 103 <CStyleOperator Value="False"/> 104 <IncludeAssertionCode Value="True"/> 105 <AllowLabel Value="False"/> 106 <CPPInline Value="False"/> 107 </SyntaxOptions> 108 </Parsing> 62 109 <CodeGeneration> 63 <Optimizations> 64 <OptimizationLevel Value="3"/> 65 </Optimizations> 110 <Checks> 111 <IOChecks Value="True"/> 112 <RangeChecks Value="True"/> 113 <OverflowChecks Value="True"/> 114 <StackChecks Value="True"/> 115 </Checks> 116 <VerifyObjMethodCallValidity Value="True"/> 66 117 </CodeGeneration> 67 118 <Linking> 119 <Debugging> 120 <DebugInfoType Value="dsDwarf2Set"/> 121 <UseHeaptrc Value="True"/> 122 <UseExternalDbgSyms Value="True"/> 123 </Debugging> 68 124 <Options> 69 125 <Win32>
Note:
See TracChangeset
for help on using the changeset viewer.