Ignore:
Timestamp:
Aug 9, 2018, 9:45:07 AM (6 years ago)
Author:
chronos
Message:
  • Added: More processor instructions.
Location:
branches/virtcpu fixed int
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/virtcpu fixed int

    • Property svn:ignore
      •  

        old new  
        33virtcpu.lps
        44virtcpu.res
         5*.dbg
  • branches/virtcpu fixed int/UMachine.pas

    r164 r165  
    55{$DEFINE EXT_ARITHMETIC}
    66{$DEFINE EXT_CONDITIONAL}
    7 //{$DEFINE EXT_LOGICAL}
     7{$DEFINE EXT_LOGICAL}
    88{$DEFINE EXT_STACK}
    99{$DEFINE EXT_SUBROUTINE}
    10 //{$DEFINE EXT_SHIFT}
     10{$DEFINE EXT_SHIFT}
    1111//{$DEFINE EXT_BLOCK}
    1212{$DEFINE EXT_GENERAL}
    1313//{$DEFINE EXT_BIT}
     14//{$DEFINE EXT_REL_JUMP}
    1415
    1516// Extension dependencies
     
    3031
    3132  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}
    3744    {$IFDEF EXT_CONDITIONAL}
    3845    opJumpRelCond, opJumpCond, opTestEqual, opTestNotEqual, opTestLess,
     
    5360    OpcodeHandlers: array[TOpcode] of TOpcodeHandler;
    5461    function ReadNext: T; inline;
     62    procedure OpcodeNop;
    5563    procedure OpcodeHalt;
    56     procedure OpcodeNop;
    5764    procedure OpcodeLoad;
    5865    procedure OpcodeLoadConst;
     66    procedure OpcodeJump;
     67    procedure OpcodeJumpRel;
     68    procedure OpcodeNeg;
     69    procedure OpcodeInc;
     70    procedure OpcodeDec;
    5971    {$IFDEF EXT_MEMORY}
    6072    procedure OpcodeLoadMem;
    6173    procedure OpcodeStoreMem;
    6274    {$ENDIF}
    63     procedure OpcodeNeg;
    6475    {$IFDEF EXT_GENERAL}
    6576    procedure OpcodeExchange;
    6677    {$ENDIF}
    67     procedure OpcodeJump;
    68     procedure OpcodeJumpRel;
    6978    {$IFDEF EXT_CONDITIONAL}
    7079    procedure OpcodeTestEqual;
     
    7584    procedure OpcodeTestLess;
    7685    procedure OpcodeJumpCond;
     86    {$IFDEF EXT_REL_JUMP}
    7787    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;
    7898    {$ENDIF}
    7999    {$IFDEF EXT_STACK}
     
    83103    {$IFDEF EXT_SUBROUTINE}
    84104    procedure OpcodeCall;
     105    {$IFDEF EXT_REL_JUMP}
    85106    procedure OpcodeCallRel;
     107    {$ENDIF}
    86108    procedure OpcodeReturn;
    87109    {$ENDIF}
     
    90112    procedure OpcodeInput;
    91113    {$ENDIF}
    92     procedure OpcodeInc;
    93     procedure OpcodeDec;
    94114    {$IFDEF EXT_ARITHMETIC}
    95115    procedure OpcodeAdd;
     
    245265end;
    246266
     267{$IFDEF EXT_REL_JUMP}
    247268procedure TCPU.OpcodeJumpRelCond;
    248269begin
    249270  if Condition then IP := IP + ReadNext;
     271end;
     272{$ENDIF}
     273{$ENDIF}
     274
     275{$IFDEF EXT_SHIFT}
     276procedure TCPU.OpcodeShl;
     277var
     278  P1, P2: T;
     279begin
     280  P1 := ReadNext;
     281  P2 := ReadNext;
     282  Registers[P1] := Registers[P1] shl Registers[P2];
     283end;
     284
     285procedure TCPU.OpcodeShr;
     286var
     287  P1, P2: T;
     288begin
     289  P1 := ReadNext;
     290  P2 := ReadNext;
     291  Registers[P1] := Registers[P1] shr Registers[P2];
     292end;
     293{$ENDIF}
     294
     295{$IFDEF EXT_LOGICAL}
     296procedure TCPU.OpcodeAnd;
     297var
     298  P1, P2: T;
     299begin
     300  P1 := ReadNext;
     301  P2 := ReadNext;
     302  Registers[P1] := Registers[P1] and Registers[P2];
     303end;
     304
     305procedure TCPU.OpcodeOr;
     306var
     307  P1, P2: T;
     308begin
     309  P1 := ReadNext;
     310  P2 := ReadNext;
     311  Registers[P1] := Registers[P1] or Registers[P2];
     312end;
     313
     314procedure TCPU.OpcodeXor;
     315var
     316  P1, P2: T;
     317begin
     318  P1 := ReadNext;
     319  P2 := ReadNext;
     320  Registers[P1] := Registers[P1] xor Registers[P2];
    250321end;
    251322{$ENDIF}
     
    276347end;
    277348
     349{$IFDEF EXT_REL_JUMP}
    278350procedure TCPU.OpcodeCallRel;
    279351var
     
    285357  IP := IP + Addr;
    286358end;
     359{$ENDIF}
    287360
    288361procedure TCPU.OpcodeReturn;
     
    386459  OpcodeHandlers[opHalt] := OpcodeHalt;
    387460  OpcodeHandlers[opLoadConst] := OpcodeLoadConst;
     461  OpcodeHandlers[opNeg] := OpcodeNeg;
     462  OpcodeHandlers[opJump] := OpcodeJump;
     463  {$IFDEF EXT_REL_JUMP}
     464  OpcodeHandlers[opJumpRel] := OpcodeJumpRel;
     465  {$ENDIF}
    388466  {$IFDEF EXT_MEMORY}
    389467  OpcodeHandlers[opLoadMem] := OpcodeLoadMem;
    390468  OpcodeHandlers[opStoreMem] := OpcodeStoreMem;
    391469  {$ENDIF}
    392   OpcodeHandlers[opNeg] := OpcodeNeg;
    393   OpcodeHandlers[opJump] := OpcodeJump;
    394   OpcodeHandlers[opJumpRel] := OpcodeJumpRel;
    395470  {$IFDEF EXT_GENERAL}
    396471  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;
    397481  {$ENDIF}
    398482  {$IFDEF EXT_STACK}
     
    402486  {$IFDEF EXT_SUBROUTINE}
    403487  OpcodeHandlers[opCall] := OpcodeCall;
     488  {$IFDEF EXT_REL_JUMP}
    404489  OpcodeHandlers[opCallRel] := OpcodeCallRel;
     490  {$ENDIF}
    405491  OpcodeHandlers[opRet] := OpcodeReturn;
    406492  {$ENDIF}
     
    417503  {$IFDEF EXT_ARITHMETIC}
    418504  OpcodeHandlers[opJumpCond] := OpcodeJumpCond;
     505  {$IFDEF EXT_REL_JUMP}
    419506  OpcodeHandlers[opJumpRelCond] := OpcodeJumpRelCond;
     507  {$ENDIF}
    420508  OpcodeHandlers[opTestEqual] := OpcodeTestEqual;
    421509  OpcodeHandlers[opTestNotEqual] := OpcodeTestNotEqual;
Note: See TracChangeset for help on using the changeset viewer.