Einzelnen Beitrag anzeigen

Blup

Registriert seit: 7. Aug 2008
Ort: Brandenburg
1.429 Beiträge
 
Delphi 10.4 Sydney
 
#26

AW: Datentypen von String zu Byte und wieder zurück

  Alt 3. Mai 2017, 09:17
Ein anderer Weg, mit reinem Assembler geht das natürlich noch kompakter:
Delphi-Quellcode:
function Rol(const AValue: LongWord; const ACount: Byte): LongWord; register;
asm
  mov cl, dl
  rol eax, cl
end;

function IntConvert(A, B: LongWord): Int64;
var
  i: integer;
begin
  Result := 0;
  for i := 0 to 31 do
  begin
    Result := Result shl 1;
    B := Rol(B, 1);
    Result := Result or (B and $00000001);

    Result := Result shl 1;
    A := Rol(A, 1);
    Result := Result or (A and $00000001);
  end;
end;

function Convert(const A, B: string): string;
var
  aa, bb: LongWord;
begin
  aa := StrToInt('$' + A);
  bb := StrToInt('$' + B);
  Result := IntToHex(IntConvert(aa, bb), 16);
end;
  Mit Zitat antworten Zitat