Ignore:
Timestamp:
Apr 13, 2019, 1:32:32 PM (6 years ago)
Author:
chronos
Message:
  • Fixed: Allow to use multiple prefix instructions in row.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/virtualcpu4/UInstructionWriter.pas

    r181 r182  
    1414  TInstructionWriter = class
    1515  private
    16     DataSizeLast: TBitWidth;
    17     DataSizePrefix: TBitWidth;
    18     AddrSizeLast: TBitWidth;
    19     AddrSizePrefix: TBitWidth;
    2016    procedure PrefixBegin;
    2117    procedure PrefixEnd;
     
    2420    IP: Integer;
    2521    DataSize: TBitWidth;
     22    DataSizeBase: TBitWidth;
    2623    AddrSize: TBitWidth;
     24    AddrSizeBase: TBitWidth;
     25    Prefix: Boolean;
    2726    procedure Init;
    2827    procedure Write8(Value: Byte);
     
    162161  Write8(Byte(opJumpRelZero));
    163162  WriteAddressSigned(Int64(Addr) - Int64(NextIP));
    164   if AddrSizeLast <> bwNone then AddrSize := AddrSizeLast;
    165163  PrefixEnd;
    166164end;
     
    199197procedure TInstructionWriter.DataPrefix8;
    200198begin
    201   DataSizePrefix := bw8;
     199  Prefix := True;
     200  DataSize := bw8;
    202201  Write8(Byte(opDataPrefix8));
    203202end;
     
    205204procedure TInstructionWriter.DataPrefix16;
    206205begin
    207   DataSizePrefix := bw16;
     206  Prefix := True;
     207  DataSize := bw16;
    208208  Write8(Byte(opDataPrefix16));
    209209end;
     
    211211procedure TInstructionWriter.DataPrefix32;
    212212begin
    213   DataSizePrefix := bw32;
     213  Prefix := True;
     214  DataSize := bw32;
    214215  Write8(Byte(opDataPrefix32));
    215216end;
     
    217218procedure TInstructionWriter.DataPrefix64;
    218219begin
    219   DataSizePrefix := bw64;
     220  Prefix := True;
     221  DataSize := bw64;
    220222  Write8(Byte(opDataPrefix64));
    221223end;
     
    223225procedure TInstructionWriter.AddrPrefix8;
    224226begin
    225   AddrSizePrefix := bw8;
     227  Prefix := True;
     228  AddrSize := bw8;
    226229  Write8(Byte(opAddrPrefix8));
    227230end;
     
    229232procedure TInstructionWriter.AddrPrefix16;
    230233begin
    231   AddrSizePrefix := bw16;
     234  Prefix := True;
     235  AddrSize := bw16;
    232236  Write8(Byte(opAddrPrefix16));
    233237end;
     
    235239procedure TInstructionWriter.AddrPrefix32;
    236240begin
    237   AddrSizePrefix := bw32;
     241  Prefix := True;
     242  AddrSize := bw32;
    238243  Write8(Byte(opAddrPrefix32));
    239244end;
     
    241246procedure TInstructionWriter.AddrPrefix64;
    242247begin
    243   AddrSizePrefix := bw64;
     248  Prefix := True;
     249  AddrSize := bw64;
    244250  Write8(Byte(opAddrPrefix64));
    245251end;
     
    297303procedure TInstructionWriter.PrefixBegin;
    298304begin
    299   if DataSizePrefix <> bwNone then begin
    300     DataSizeLast := DataSize;
    301     DataSize := DataSizePrefix;
    302     DataSizePrefix := bwNone;
    303   end;
    304   if AddrSizePrefix <> bwNone then begin
    305     AddrSizeLast := AddrSize;
    306     AddrSize := AddrSizePrefix;
    307     AddrSizePrefix := bwNone;
    308   end;
     305  Prefix := False;
    309306end;
    310307
    311308procedure TInstructionWriter.PrefixEnd;
    312309begin
    313   if DataSizeLast <> bwNone then begin
    314     DataSize := DataSizeLast;
    315     DataSizeLast := bwNone;
    316   end;
    317   if AddrSizeLast <> bwNone then begin
    318     AddrSize := AddrSizeLast;
    319     AddrSizeLast := bwNone;
     310  if not Prefix then begin
     311    DataSize := DataSizeBase;
     312    AddrSize := AddrSizeBase;
    320313  end;
    321314end;
     
    323316procedure TInstructionWriter.Init;
    324317begin
    325   DataSize := Cpu.DataSize;
    326   AddrSize := Cpu.AddrSize;
     318  DataSizeBase := Cpu.DataSizeBase;
     319  DataSize := DataSizeBase;
     320  AddrSizeBase := Cpu.AddrSizeBase;
     321  AddrSize := AddrSizeBase;
    327322end;
    328323
Note: See TracChangeset for help on using the changeset viewer.