procedure TForm1.FormCreate(Sender: TObject); var S: string; Buf: array[0..MAXBYTE-1] of Char; iLen, I, iSum: Integer; begin S := '8B 6B 36 33'; S := StringReplace(S, ' ', '', [rfReplaceAll]); FillChar(Buf, MAXBYTE, 0); iLen := HexToBin(@S[1], Buf, MAXBYTE); iSum := 0; for I := 0 to iLen - 1 do begin Buf[I] := Chr(Ord(Buf[I]) - $33); Inc(iSum, Ord(Buf[I]) shl (8 * I)) end; ShowMessage(FloatToStr(iSum / $100)) end;
procedure TForm1.Button1Click(Sender: TObject); var X, Z : string; Y, I: Integer; B: Byte; begin X := '8B6B3633'; Y := StrtoInt('$'+X) - StrtoInt('$'+'33333333'); Showmessage(Format('%.4x',[Y])); Z := ''; for I := 0 to 3 do begin B := Y shr (8*I); Z := Z + Format('%.2x', [B]); end; Showmessage(Z); end; //除以100的事,自己做吧
var s: string; v: integer; fv: double; begin s := '8B6B3633'; v := StrToInt('$'+ s) - StrToInt('$33333333'); BinToHex(@v, @s[1], 4); fv := StrToInt(s) / 100; ShowMessage(FloatToStr(fv)); end;
var s: integer; begin asm mov eax, $8B6B3633 - $33333333 bswap eax mov s,eax end; ShowMessage(FloatToStr(s / $100)); end;
楼上请看清楚LZ问题,是16进制字符串“8B6B3633”
转换一下不结了么 var sd: string; s: integer; begin sd := '8B6B3633'; s := strtoint('$' + sd) - $33333333; asm mov eax,s bswap eax mov s,eax end; ShowMessage(FloatToStr(s / $100)); end;
其他的for循环
var
S: string;
Buf: array[0..MAXBYTE-1] of Char;
iLen, I, iSum: Integer;
begin
S := '8B 6B 36 33'; S := StringReplace(S, ' ', '', [rfReplaceAll]);
FillChar(Buf, MAXBYTE, 0);
iLen := HexToBin(@S[1], Buf, MAXBYTE); iSum := 0;
for I := 0 to iLen - 1 do
begin
Buf[I] := Chr(Ord(Buf[I]) - $33);
Inc(iSum, Ord(Buf[I]) shl (8 * I))
end; ShowMessage(FloatToStr(iSum / $100))
end;
procedure TForm1.Button1Click(Sender: TObject);
var
X, Z : string;
Y, I: Integer;
B: Byte;
begin
X := '8B6B3633';
Y := StrtoInt('$'+X) - StrtoInt('$'+'33333333');
Showmessage(Format('%.4x',[Y]));
Z := '';
for I := 0 to 3 do begin
B := Y shr (8*I);
Z := Z + Format('%.2x', [B]);
end;
Showmessage(Z);
end;
//除以100的事,自己做吧
s: string;
v: integer;
fv: double;
begin
s := '8B6B3633';
v := StrToInt('$'+ s) - StrToInt('$33333333');
BinToHex(@v, @s[1], 4);
fv := StrToInt(s) / 100;
ShowMessage(FloatToStr(fv));
end;
var
s: integer;
begin
asm
mov eax, $8B6B3633 - $33333333
bswap eax
mov s,eax
end;
ShowMessage(FloatToStr(s / $100));
end;
转换一下不结了么
var
sd: string;
s: integer;
begin
sd := '8B6B3633';
s := strtoint('$' + sd) - $33333333;
asm
mov eax,s
bswap eax
mov s,eax
end;
ShowMessage(FloatToStr(s / $100));
end;