Changeset 185 for branches/virtualcpu4/UOpcode.pas
- Timestamp:
- May 1, 2019, 9:48:46 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/virtualcpu4/UOpcode.pas
r184 r185 29 29 end; 30 30 31 function IntToHexEx(Value: Int64; Digits: ShortInt; Prefix: string = ''): string; overload; 32 function IntToHexEx(Value: QWord; Digits: ShortInt; Prefix: string = ''): string; overload; 33 31 34 32 35 implementation 36 37 const 38 HexChars: array[0..15] of Char = '0123456789ABCDEF'; 39 40 function IntToHexEx(Value: Int64; Digits: ShortInt; Prefix: string = ''): string; 41 var 42 I: Integer; 43 Negative: Boolean; 44 begin 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; 63 end; 64 65 function IntToHexEx(Value: QWord; Digits: ShortInt; Prefix: string = ''): string; 66 var 67 I: Integer; 68 begin 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; 84 end; 33 85 34 86 { TOpcodeDefs } … … 100 152 AddNew(opShr, 'SHR', prReg, prReg, prNone, False); 101 153 AddNew(opDataPrefix8, 'DP8', prNone, prNone, prNone, True); 102 AddNew(opDataPrefix16, 'DP16', prNone, prNone, prNone, False);154 AddNew(opDataPrefix16, 'DP16', prNone, prNone, prNone, True); 103 155 AddNew(opDataPrefix32, 'DP32', prNone, prNone, prNone, True); 104 156 AddNew(opDataPrefix64, 'DP64', prNone, prNone, prNone, True); … … 117 169 AddNew(opAddrPrefix16, 'AP16', prNone, prNone, prNone, True); 118 170 AddNew(opAddrPrefix32, 'AP32', prNone, prNone, prNone, True); 119 AddNew(op DataPrefix64, 'AP64', prNone, prNone, prNone, True);171 AddNew(opAddrPrefix64, 'AP64', prNone, prNone, prNone, True); 120 172 AddNew(opConvert, 'CON', prReg, prNone, prNone, True); 121 173 end;
Note:
See TracChangeset
for help on using the changeset viewer.