Setting a given bit (0-31) in an integer

function SetBit(const Value, Pos: Integer): Integer;
asm
  and edx, 31
  bts eax, edx
end;

Source: www.guidogybels.net.