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/UOpcode.pas

    r184 r185  
    2929  end;
    3030
     31  function IntToHexEx(Value: Int64; Digits: ShortInt; Prefix: string = ''): string; overload;
     32  function IntToHexEx(Value: QWord; Digits: ShortInt; Prefix: string = ''): string; overload;
     33
    3134
    3235implementation
     36
     37const
     38  HexChars: array[0..15] of Char = '0123456789ABCDEF';
     39
     40function IntToHexEx(Value: Int64; Digits: ShortInt; Prefix: string = ''): string;
     41var
     42  I: Integer;
     43  Negative: Boolean;
     44begin
     45  Negative := Value < 0;
     46  if Negative then Value := -Value;
     47  Result := '';
     48  if Digits >= 0 then begin
     49    for I := 0 to Digits - 1 do begin
     50      Result := HexChars[Value and $f] + Result;
     51      Value := Value shr 4;
     52    end;
     53  end else begin
     54    if Value <> 0 then begin
     55      while QWord(Value) > 0 do begin
     56        Result := HexChars[Value and $f] + Result;
     57        Value := Value shr 4;
     58      end;
     59    end else Result := '0';
     60  end;
     61  Result := Prefix + Result;
     62  if Negative then Result := '-' + Result;
     63end;
     64
     65function IntToHexEx(Value: QWord; Digits: ShortInt; Prefix: string = ''): string;
     66var
     67  I: Integer;
     68begin
     69  Result := '';
     70  if Digits >= 0 then begin
     71    for I := 0 to Digits - 1 do begin
     72      Result := HexChars[Value and $f] + Result;
     73      Value := Value shr 4;
     74    end;
     75  end else begin
     76    if Value <> 0 then begin
     77      while Value > 0 do begin
     78        Result := HexChars[Value and $f] + Result;
     79        Value := Value shr 4;
     80      end;
     81    end else Result := '0';
     82  end;
     83  Result := Prefix + Result;
     84end;
    3385
    3486{ TOpcodeDefs }
     
    100152  AddNew(opShr, 'SHR', prReg, prReg, prNone, False);
    101153  AddNew(opDataPrefix8, 'DP8', prNone, prNone, prNone, True);
    102   AddNew(opDataPrefix16, 'DP16', prNone, prNone, prNone, False);
     154  AddNew(opDataPrefix16, 'DP16', prNone, prNone, prNone, True);
    103155  AddNew(opDataPrefix32, 'DP32', prNone, prNone, prNone, True);
    104156  AddNew(opDataPrefix64, 'DP64', prNone, prNone, prNone, True);
     
    117169  AddNew(opAddrPrefix16, 'AP16', prNone, prNone, prNone, True);
    118170  AddNew(opAddrPrefix32, 'AP32', prNone, prNone, prNone, True);
    119   AddNew(opDataPrefix64, 'AP64', prNone, prNone, prNone, True);
     171  AddNew(opAddrPrefix64, 'AP64', prNone, prNone, prNone, True);
    120172  AddNew(opConvert, 'CON', prReg, prNone, prNone, True);
    121173end;
Note: See TracChangeset for help on using the changeset viewer.