Ignore:
Timestamp:
Oct 16, 2018, 11:03:59 AM (6 years ago)
Author:
chronos
Message:
  • Added: Show CPU tick count.
  • Added: Show IP register value.
  • Modified: Condition instructions store result to R1 register rather then to condition boolean variable.
  • Modified: Shorter InstructionWriter method names.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/virtcpu fixed int/UInstructionWriter.pas

    r165 r168  
    1717    IP: T;
    1818    procedure Write(Value: T);
    19     procedure AddNop;
    20     procedure AddLd(R1, R2: Integer);
    21     procedure AddHalt;
    22     procedure AddLdc(R, Value: Integer);
    23     procedure AddLdm(R1, R2: Integer);
    24     procedure AddStm(R1, R2: Integer);
    25     procedure AddNeg(R: Integer);
    26     procedure AddIn(R1, R2: Integer);
    27     procedure AddOut(R1, R2: Integer);
    28     procedure AddJump(Addr: Integer);
    29     {$IFDEF EXT_REL_JUMP}procedure AddJr(Addr: Integer);{$ENDIF}
    30     procedure AddInc(R: Integer);
     19    procedure NoOperation;
     20    procedure Load(R1, R2: Integer);
     21    procedure Halt;
     22    procedure LoadConst(R, Value: Integer);
     23    procedure LoadMemory(R1, R2: Integer);
     24    procedure StoreMemory(R1, R2: Integer);
     25    procedure Neg(R: Integer);
     26    procedure Input(R1, R2: Integer);
     27    procedure Output(R1, R2: Integer);
     28    procedure Subtract(R1, R2: Integer);
     29    procedure Jump(Addr: Integer);
     30    procedure JumpNotZero(R1: Integer; Addr: Integer);
     31    procedure JumpZero(R1: Integer; Addr: Integer);
     32    {$IFDEF EXT_REL_JUMP}procedure JumpRelative(Addr: Integer);{$ENDIF}
     33    procedure Increment(R: Integer);
     34    procedure Decrement(R: Integer);
    3135    constructor Create;
    3236  end;
     
    3741{ TInstructionWriter }
    3842
    39 procedure TInstructionWriter.AddNop;
     43procedure TInstructionWriter.NoOperation;
    4044begin
    4145  Write(T(opNop));
    4246end;
    4347
    44 procedure TInstructionWriter.AddLd(R1, R2: Integer);
     48procedure TInstructionWriter.Load(R1, R2: Integer);
    4549begin
    4650  Write(T(opLoad));
     
    4953end;
    5054
    51 procedure TInstructionWriter.AddHalt;
     55procedure TInstructionWriter.Halt;
    5256begin
    5357  Write(T(opHalt));
    5458end;
    5559
    56 procedure TInstructionWriter.AddLdc(R, Value: Integer);
     60procedure TInstructionWriter.LoadConst(R, Value: Integer);
    5761begin
    5862  Write(T(opLoadConst));
     
    6165end;
    6266
    63 procedure TInstructionWriter.AddLdm(R1, R2: Integer);
     67procedure TInstructionWriter.LoadMemory(R1, R2: Integer);
    6468begin
    6569  Write(T(opLoadMem));
     
    6872end;
    6973
    70 procedure TInstructionWriter.AddStm(R1, R2: Integer);
     74procedure TInstructionWriter.StoreMemory(R1, R2: Integer);
    7175begin
    7276  Write(T(opStoreMem));
     
    7579end;
    7680
    77 procedure TInstructionWriter.AddNeg(R: Integer);
     81procedure TInstructionWriter.Neg(R: Integer);
    7882begin
    7983  Write(T(opNeg));
     
    8185end;
    8286
    83 procedure TInstructionWriter.AddIn(R1, R2: Integer);
     87procedure TInstructionWriter.Input(R1, R2: Integer);
    8488begin
    8589  Write(T(opInput));
     
    8892end;
    8993
    90 procedure TInstructionWriter.AddOut(R1, R2: Integer);
     94procedure TInstructionWriter.Output(R1, R2: Integer);
    9195begin
    9296  Write(T(opOutput));
     
    9599end;
    96100
    97 procedure TInstructionWriter.AddJump(Addr: Integer);
     101procedure TInstructionWriter.Subtract(R1, R2: Integer);
     102begin
     103  Write(T(opSub));
     104  Write(R1);
     105  Write(R2);
     106end;
     107
     108procedure TInstructionWriter.Jump(Addr: Integer);
    98109begin
    99110  Write(T(opJump));
     
    101112end;
    102113
     114procedure TInstructionWriter.JumpNotZero(R1: Integer; Addr: Integer);
     115begin
     116  Write(T(opJumpNotZero));
     117  Write(R1);
     118  Write(Addr);
     119end;
     120
     121procedure TInstructionWriter.JumpZero(R1: Integer; Addr: Integer);
     122begin
     123  Write(T(opJumpZero));
     124  Write(R1);
     125  Write(Addr);
     126end;
     127
    103128{$IFDEF EXT_REL_JUMP}
    104 procedure TInstructionWriter.AddJr(Addr: Integer);
     129procedure TInstructionWriter.JumpRelative(Addr: Integer);
    105130begin
    106131  Write(T(opJumpRel));
     
    109134{$ENDIF}
    110135
    111 procedure TInstructionWriter.AddInc(R: Integer);
     136procedure TInstructionWriter.Increment(R: Integer);
    112137begin
    113138  Write(T(opInc));
     139  Write(R);
     140end;
     141
     142procedure TInstructionWriter.Decrement(R: Integer);
     143begin
     144  Write(T(opDec));
    114145  Write(R);
    115146end;
Note: See TracChangeset for help on using the changeset viewer.