Ignore:
Timestamp:
Apr 24, 2019, 5:04:53 PM (6 years ago)
Author:
chronos
Message:
  • Added: New instruction Convert which can convert numbers between different widths.
Location:
branches/virtualcpu4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/virtualcpu4

    • Property svn:ignore
      •  

        old new  
        55*.res
        66heaptrclog.trc
         7*.dbg
  • branches/virtualcpu4/UCpu.pas

    r182 r183  
    1515    opDataPrefix32, opDataPrefix64, opDataSize, opAddrSize, opTest, opAnd, opOr,
    1616    opXor, opLddr, opLdir, opMul, opDiv, opMod, opAddrPrefix8, opAddrPrefix16,
    17     opAddrPrefix32, opAddrPrefix64);
     17    opAddrPrefix32, opAddrPrefix64, opConvert);
    1818
    1919  TAddressSigned = Int64;
     
    5151    Z: Boolean;
    5252    Thread: TCpuThread;
     53    procedure InstConvert;
    5354    procedure InstNop;
    5455    procedure InstHalt;
     
    197198    (Name: 'AP16'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True),
    198199    (Name: 'AP32'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True),
    199     (Name: 'AP64'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True)
     200    (Name: 'AP64'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True),
     201    (Name: 'CON'; Param1: prReg; Param2: prNone; Param3: prNone; Prefix: True)
    200202  );
    201203
     
    770772  end;
    771773end;
     774
     775procedure TCpu.InstConvert;
     776var
     777  R: TRegIndex;
     778begin
     779  R := Read8;
     780  case AddrSize of
     781    bw8: case DataSize of
     782      bw8: Registers[R].B := Registers[R].B;
     783      bw16: Registers[R].B := Registers[R].W;
     784      bw32: Registers[R].B := Registers[R].D;
     785      bw64: Registers[R].B := Registers[R].Q;
     786    end;
     787    bw16: case DataSize of
     788      bw8: Registers[R].W := Registers[R].B;
     789      bw16: Registers[R].W := Registers[R].W;
     790      bw32: Registers[R].W := Registers[R].D;
     791      bw64: Registers[R].W := Registers[R].Q;
     792    end;
     793    bw32: case DataSize of
     794      bw8: Registers[R].D := Registers[R].B;
     795      bw16: Registers[R].D := Registers[R].W;
     796      bw32: Registers[R].D := Registers[R].D;
     797      bw64: Registers[R].D := Registers[R].Q;
     798    end;
     799    bw64: case DataSize of
     800      bw8: Registers[R].Q := Registers[R].B;
     801      bw16: Registers[R].Q := Registers[R].W;
     802      bw32: Registers[R].Q := Registers[R].D;
     803      bw64: Registers[R].Q := Registers[R].Q;
     804    end;
     805  end;
     806end;
     807
    772808
    773809procedure TCpu.InstLddr;
     
    10881124  Instructions[opDataPrefix16] := InstDataPrefix16;
    10891125  Instructions[opDataPrefix32] := InstDataPrefix32;
    1090   Instructions[opDataPrefix32] := InstDataPrefix64;
     1126  Instructions[opDataPrefix64] := InstDataPrefix64;
    10911127  Instructions[opAddrSize] := InstAddrSize;
    10921128  Instructions[opAddrPrefix8] := InstAddrPrefix8;
    10931129  Instructions[opAddrPrefix16] := InstAddrPrefix16;
    10941130  Instructions[opAddrPrefix32] := InstAddrPrefix32;
    1095   Instructions[opAddrPrefix32] := InstAddrPrefix64;
     1131  Instructions[opAddrPrefix64] := InstAddrPrefix64;
    10961132  Instructions[opTest] := InstTest;
    10971133  Instructions[opAnd] := InstAnd;
     
    11031139  Instructions[opDiv] := InstDiv;
    11041140  Instructions[opMod] := InstMod;
     1141  Instructions[opConvert] := InstConvert;
    11051142end;
    11061143
Note: See TracChangeset for help on using the changeset viewer.