kirchfritz hat geschrieben: Do 11. Jul 2024, 11:49 Ich wollte eigentlich nur die Bedeutung von
verstehen, und wie man das in PASCAL - Syntax übersetzt.Code: Alles auswählen
const byte ByteMask = 0b11111111; UINt32 a = (value >> 24) & ByteMask; UINt32 b = (value >> 16) & ByteMask; UINt32 c = (value >> 8) & ByteMask; UINt32 d = (value >> 0) & ByteMask; value = a << 0 | b << 8 | c << 16 | d <<24
Code: Alles auswählen
procedure TForm1.Button1Click(Sender: TObject);
const
ByteMask = %11111111;
var
Value, a, b, c, d: Cardinal;
begin
Value := $FF00;
Memo1.Lines.add(Value.ToHexString);
//1:1 in Pascal Syntax übersetzt:
a := (Value shr 24) and ByteMask;
b := (Value shr 16) and ByteMask;
c := (Value shr 8) and ByteMask;
d := (Value shr 0) and ByteMask;
Value := a shl 0 or b shl 8 or c shl 16 or d shl 24;
Memo1.Lines.add(Value.ToHexString());
//Oder einfach:
Value := $FF00;
Memo1.Lines.add(Value.ToHexString);
Value:=SwapEndian(Value);
Memo1.Lines.add(Value.ToHexString);
end;