/// Multiply unsigned 32-bit integers a and b, store the low 32-bits of the result in dst, and store the high 32-bits in hi. This does not read or write arithmetic flags.
/// </summary>
/// <remarks>
/// **** mulx r32, r32, m32
/// </remarks>
/// <param name="a">32-bit integer</param>
/// <param name="b">32-bit integer</param>
/// <param name="hi">Stores the high 32-bits</param>
/// <returns>32-bit integer</returns>
[DebuggerStepThrough]
publicstaticuintmulx_u32(uinta,uintb,outuinthi)
{
ulongaBig=a;
ulongbBig=b;
ulongresult=aBig*bBig;
hi=(uint)(result>>32);
return(uint)(result&0xffffffff);
}
/// <summary>
/// Multiply unsigned 64-bit integers a and b, store the low 64-bits of the result in dst, and store the high 64-bits in hi. This does not read or write arithmetic flags.
/// </summary>
/// <remarks>
/// **** mulx r64, r64, m64
/// </remarks>
/// <param name="a">64-bit integer</param>
/// <param name="b">64-bit integer</param>
/// <param name="hi">Stores the high 64-bits</param>
/// Deposit contiguous low bits from unsigned 32-bit integer a to dst at the corresponding bit locations specified by mask; all other bits in dst are set to zero.
/// </summary>
/// <remarks>
/// **** pdep r32, r32, r32
/// </remarks>
/// <param name="a">32-bit integer</param>
/// <param name="mask">Mask</param>
/// <returns>32-bit integer</returns>
[DebuggerStepThrough]
publicstaticuintpdep_u32(uinta,uintmask)
{
uintresult=0;
intk=0;
for(inti=0;i<32;i++)
{
if((mask&(1u<<i))!=0)
{
result|=((a>>k)&1u)<<i;
k++;
}
}
returnresult;
}
/// <summary>
/// Deposit contiguous low bits from unsigned 64-bit integer a to dst at the corresponding bit locations specified by mask; all other bits in dst are set to zero.
/// </summary>
/// <remarks>
/// **** pdep r64, r64, r64
/// </remarks>
/// <param name="a">64-bit integer</param>
/// <param name="mask">Mask</param>
/// <returns>64-bit integer</returns>
[DebuggerStepThrough]
publicstaticulongpdep_u64(ulonga,ulongmask)
{
ulongresult=0;
intk=0;
for(inti=0;i<64;i++)
{
if((mask&(1ul<<i))!=0)
{
result|=((a>>k)&1ul)<<i;
k++;
}
}
returnresult;
}
/// <summary>
/// Extract bits from unsigned 32-bit integer a at the corresponding bit locations specified by mask to contiguous low bits in dst; the remaining upper bits in dst are set to zero.
/// </summary>
/// <remarks>
/// **** pext r32, r32, r32
/// </remarks>
/// <param name="a">32-bit integer</param>
/// <param name="mask">Mask</param>
/// <returns>32-bit integer</returns>
[DebuggerStepThrough]
publicstaticuintpext_u32(uinta,uintmask)
{
uintresult=0;
intk=0;
for(inti=0;i<32;i++)
{
if((mask&(1u<<i))!=0)
{
result|=((a>>i)&1u)<<k;
k++;
}
}
returnresult;
}
/// <summary>
/// Extract bits from unsigned 64-bit integer a at the corresponding bit locations specified by mask to contiguous low bits in dst; the remaining upper bits in dst are set to zero.