Ignore:
Timestamp:
May 1, 2019, 9:48:46 PM (6 years ago)
Author:
chronos
Message:
  • Added: Assembler labels reference address calculation.
  • Fixed: Displaying address/data hex numbers in opcode and instruction.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/virtualcpu4/UDisassembler.pas

    r184 r185  
    2929
    3030implementation
    31 
    32 const
    33   SignText: array[TValueSign] of string = ('-', '', '+');
    34 
    35 function SignedIntToHex(Value: Int64; Digits: Byte): string;
    36 begin
    37   Result := SignText[Sign(Value)] + IntToHex(Abs(Value), Digits);
    38 end;
    3931
    4032{ TDisassembler }
     
    8476          Data := ReadData;
    8577          Line.Opcode := Line.Opcode + ' ' + IntToHex(Data, BitWidthBytes[DataSize] * 2);
    86           Line.Instruction := Line.Instruction + ' $' + IntToHex(Data, BitWidthBytes[DataSize] * 2);
     78          Line.Instruction := Line.Instruction + ' ' + IntToHexEx(Data, -1, '$');
    8779        end;
    8880        prAddr: begin
    8981          Address := ReadAddress;
    9082          Line.Opcode := Line.Opcode + ' ' + IntToHex(Address, BitWidthBytes[AddrSize] * 2);
    91           Line.Instruction := Line.Instruction + ' $' + IntToHex(Address, BitWidthBytes[AddrSize] * 2);
     83          Line.Instruction := Line.Instruction + ' ' + IntToHexEx(Address, -1, '$');
    9284        end;
    9385        prAddrRel: begin
    9486          AddressRel := ReadAddressSigned;
    95           Line.Opcode := Line.Opcode + ' ' + IntToHex(QWord(AddressRel), BitWidthBytes[AddrSize] * 2);
    96           Line.Instruction := Line.Instruction + ' $' + SignedIntToHex(AddressRel, BitWidthBytes[AddrSize] * 2);
     87          Line.Opcode := Line.Opcode + ' ' + IntToHexEx(QWord(AddressRel), BitWidthBytes[AddrSize] * 2);
     88          Line.Instruction := Line.Instruction + ' ' + IntToHexEx(AddressRel, -1, '$');
    9789        end;
    9890      end;
     
    10597        prData: begin
    10698          Data := ReadData;
    107           Line.Opcode := Line.Opcode + ' ' + IntToHex(Data, BitWidthBytes[DataSize] * 2);
    108           Line.Instruction := Line.Instruction + ', $' + IntToHex(Data, BitWidthBytes[DataSize] * 2);
     99          Line.Opcode := Line.Opcode + ' ' + IntToHexEx(Data, BitWidthBytes[DataSize] * 2);
     100          Line.Instruction := Line.Instruction + ', ' + IntToHexEx(Data, -1, '$');
    109101        end;
    110102        prAddr: begin
    111103          Address := ReadAddress;
    112104          Line.Opcode := Line.Opcode + ' ' + IntToHex(Address, BitWidthBytes[AddrSize] * 2);
    113           Line.Instruction := Line.Instruction + ', $' + IntToHex(Address, BitWidthBytes[AddrSize] * 2);
     105          Line.Instruction := Line.Instruction + ', ' + IntToHexEx(Address, -1, '$');
    114106        end;
    115107        prAddrRel: begin
    116108          AddressRel := ReadAddressSigned;
    117           Line.Opcode := Line.Opcode + ' ' + IntToHex(AddressRel, BitWidthBytes[AddrSize] * 2);
    118           Line.Instruction := Line.Instruction + ', $' + SignedIntToHex(AddressRel, BitWidthBytes[AddrSize] * 2);
     109          Line.Opcode := Line.Opcode + ' ' + IntToHex(QWord(AddressRel), BitWidthBytes[AddrSize] * 2);
     110          Line.Instruction := Line.Instruction + ', ' + IntToHexEx(AddressRel, -1, '$');
    119111        end;
    120112      end;
     
    128120          Data := ReadData;
    129121          Line.Opcode := Line.Opcode + ' ' + IntToHex(Data, BitWidthBytes[DataSize] * 2);
    130           Line.Instruction := Line.Instruction + ', $' + IntToHex(Data, BitWidthBytes[DataSize] * 2);
     122          Line.Instruction := Line.Instruction + ', ' + IntToHexEx(Data, -1, '$');
    131123        end;
    132124        prAddr: begin
    133125          Address := ReadAddress;
    134126          Line.Opcode := Line.Opcode + ' ' + IntToHex(Address, BitWidthBytes[AddrSize] * 2);
    135           Line.Instruction := Line.Instruction + ', $' + IntToHex(Address, BitWidthBytes[AddrSize] * 2);
     127          Line.Instruction := Line.Instruction + ', ' + IntToHexEx(Address, -1, '$');
    136128        end;
    137129        prAddrRel: begin
    138130          AddressRel := ReadAddressSigned;
    139131          Line.Opcode := Line.Opcode + ' ' + IntToHex(QWord(AddressRel), BitWidthBytes[AddrSize] * 2);
    140           Line.Instruction := Line.Instruction + ', $' + SignedIntToHex(AddressRel, BitWidthBytes[AddrSize] * 2);
     132          Line.Instruction := Line.Instruction + ', ' + IntToHexEx(AddressRel, -1, '$');
    141133        end;
    142134      end;
    143135      Output.Add(Line);
     136      if not Prefix then begin
     137        DataSize := DataSizeBase;
     138        AddrSize := AddrSizeBase;
     139      end;
    144140    end else begin
    145141      {Line := TDisassemblerLine.Create;
     
    149145      Output.Add(Line);
    150146      }
    151     end;
    152     if not Prefix then begin
    153       DataSize := DataSizeBase;
    154       AddrSize := AddrSizeBase;
    155147    end;
    156148  end;
Note: See TracChangeset for help on using the changeset viewer.