Changeset 165 for branches/virtcpu fixed int/UMachine.pas
- Timestamp:
- Aug 9, 2018, 9:45:07 AM (6 years ago)
- Location:
- branches/virtcpu fixed int
- Files:
-
- 2 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/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;
Note:
See TracChangeset
for help on using the changeset viewer.