Zitat von
negaH:
Delphi-Quellcode:
function BitSet(Value,BitIndex: LongWord; State: Boolean): LondWord;
asm
shr ecx, 1
btc eax, edx
end;
procedure BitSet(
var Value: LongWord; BitIndex: LongWord; State: Boolean);
asm
shr ecx, 1
btc dword ptr [eax], edx
end;
dies setzt jedoch voraus, dass das betroffene Bit nicht bereits 1 war...
Zitat von
intel 8086 Family Architecture:
The destination bit indexed by the source value is copied into the Carry Flag after being complimented (inverted).
also ist doch ein Compare notwendig:
Delphi-Quellcode:
Function BitSet(
Const Value : LongWord;
Const Bit : Byte;
Const State : Boolean) : LongWord;
Asm
OR CL,CL
JNZ @@True
BTR EAX,EDX
RET
@@True:
BTS EAX,EDX
end;