Re: Structure bitweise füllen / abfragen
Verfasst: 25.08.2013 00:56
Äh... Warum so kompliziert?
Uralt von mir... 2007

P.S. Als ASM hatte ich das auch schon mal... Kann ich leider nicht wiederfinden
Uralt von mir... 2007
Code: Alles auswählen
Macro TestBit(value,bit)
(value>>bit&1)
EndMacro
Macro SetBit(value,bit)
(1 << bit | value)
EndMacro
Macro ClrBit(value,bit)
(~(1 << bit) & value)
EndMacro
Debug "Die Zahl 5 - Bit für Bit"
Val = 5
r1 = TestBit(Val,0)
Debug "Das 1. Bit: "+Str(r1)
r1 = TestBit(Val,1)
Debug "Das 2. Bit: "+Str(r1)
Debug "Das 3. Bit: "+Str(TestBit(Val,2))
Debug "Und hier in einer Zeile: "+Bin(5)
Value = 0
Debug "Setze Bit 0"
Value = SetBit(Value,0)
Debug "Setze Bit 2"
Value = SetBit(Value,2)
Debug "Ergebis= " + Str(Value)
Debug "Lösche Bit 0"
Value = ClrBit(Value, 0)
Debug "Ergebis= " + Str(Value)
lVal.l = 0
Debug "Setze Bit 31"
lVal = SetBit(lVal,31)
Debug "Ergebis= " + Str(lVal)
Debug "Ergebis= " + Bin(lVal)
llVal.q = 0
Debug "Setze Bit 63"
llVal = SetBit(llVal,63)
Debug "Ergebis= " + StrQ(llVal)
Debug "Ergebis= " + BinQ(llVal)
P.S. Als ASM hatte ich das auch schon mal... Kann ich leider nicht wiederfinden