Changeset 183


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:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/virtualcpu4

    • Property svn:ignore
      •  

        old new  
        55*.res
        66heaptrclog.trc
         7*.dbg
  • branches/virtualcpu4/Forms/UFormMain.lfm

    r181 r183  
    11object FormMain: TFormMain
    22  Left = 780
    3   Height = 269
     3  Height = 224
    44  Top = 527
    5   Width = 659
     5  Width = 549
    66  Caption = 'VirtCpu4'
    7   ClientHeight = 269
    8   ClientWidth = 659
    9   DesignTimePPI = 144
     7  ClientHeight = 224
     8  ClientWidth = 549
     9  DesignTimePPI = 120
    1010  OnCreate = FormCreate
    1111  OnDestroy = FormDestroy
    1212  OnShow = FormShow
    13   LCLVersion = '2.0.0.4'
     13  LCLVersion = '2.0.2.0'
    1414  object ButtonStart: TButton
    15     Left = 229
    16     Height = 37
    17     Top = 17
    18     Width = 113
     15    Left = 191
     16    Height = 31
     17    Top = 14
     18    Width = 94
    1919    Caption = 'Start'
    2020    OnClick = ButtonStartClick
     
    2323  end
    2424  object ButtonStop: TButton
    25     Left = 229
    26     Height = 37
    27     Top = 65
    28     Width = 113
     25    Left = 191
     26    Height = 31
     27    Top = 54
     28    Width = 94
    2929    Caption = 'Stop'
    3030    OnClick = ButtonStopClick
     
    3333  end
    3434  object ButtonDisassembler: TButton
    35     Left = 371
    36     Height = 38
    37     Top = 17
    38     Width = 185
     35    Left = 309
     36    Height = 32
     37    Top = 14
     38    Width = 154
    3939    Caption = 'Disassembler'
    4040    OnClick = ButtonDisassemblerClick
     41    ParentFont = False
    4142    TabOrder = 2
    4243  end
    4344  object ButtonMemory: TButton
    44     Left = 371
    45     Height = 38
    46     Top = 64
    47     Width = 185
     45    Left = 309
     46    Height = 32
     47    Top = 53
     48    Width = 154
    4849    Caption = 'Memory'
    4950    OnClick = ButtonMemoryClick
     51    ParentFont = False
    5052    TabOrder = 3
    5153  end
    5254  object ButtonCpuState: TButton
    53     Left = 371
    54     Height = 38
    55     Top = 111
    56     Width = 185
     55    Left = 309
     56    Height = 32
     57    Top = 92
     58    Width = 154
    5759    Caption = 'CPU state'
    5860    OnClick = ButtonCpuStateClick
     61    ParentFont = False
    5962    TabOrder = 4
    6063  end
    6164  object ButtonScreen: TButton
    62     Left = 24
    63     Height = 38
    64     Top = 16
    65     Width = 185
     65    Left = 20
     66    Height = 32
     67    Top = 13
     68    Width = 154
    6669    Caption = 'Screen'
    6770    OnClick = ButtonScreenClick
     71    ParentFont = False
    6872    TabOrder = 5
    6973  end
    7074  object ButtonConsole: TButton
    71     Left = 24
    72     Height = 38
    73     Top = 64
    74     Width = 185
     75    Left = 20
     76    Height = 32
     77    Top = 53
     78    Width = 154
    7579    Caption = 'Console'
    7680    OnClick = ButtonConsoleClick
     81    ParentFont = False
    7782    TabOrder = 6
    7883  end
  • branches/virtualcpu4/Forms/UFormMain.pas

    r182 r183  
    144144  with InstructionWriter do begin
    145145    Init;
     146    DataPrefix32; Loadi(R1, $12345678);
     147    DataPrefix8; Loadi(R1, $ff);
     148    DataPrefix8; Convert(R1);
     149
    146150    LabelMain := $100;
    147151    Jump(LabelMain);
  • 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
  • branches/virtualcpu4/UDisassembler.pas

    r182 r183  
    5656    Prefix := False;
    5757    Opcode := Read8;
    58     if Opcode < Integer(High(TOpcode)) then begin
     58    if Opcode <= Integer(High(TOpcode)) then begin
    5959      Prefix := OpcodeDef[TOpcode(Opcode)].Prefix;
    6060      case TOpcode(Opcode) of
  • branches/virtualcpu4/UInstructionWriter.pas

    r182 r183  
    4848    procedure Call(Addr: QWord);
    4949    procedure Return;
     50    procedure Convert(Reg: TRegIndex);
    5051    procedure DataPrefix8;
    5152    procedure DataPrefix16;
     
    195196end;
    196197
     198procedure TInstructionWriter.Convert(Reg: TRegIndex);
     199begin
     200  PrefixBegin;
     201  Write8(Byte(opConvert));
     202  Write8(Reg);
     203  PrefixEnd;
     204end;
     205
    197206procedure TInstructionWriter.DataPrefix8;
    198207begin
  • branches/virtualcpu4/virtucpu4.lpi

    r182 r183  
    180180      <Debugging>
    181181        <UseHeaptrc Value="True"/>
     182        <UseExternalDbgSyms Value="True"/>
    182183      </Debugging>
    183184      <Options>
Note: See TracChangeset for help on using the changeset viewer.