[.Net/MSIL] uint8/byte - bit rotate

01/21/2014 23:33 tolio#1
Weil .Net mich weder in VB noch C# code kompilieren lässt mit welchem ich Bits in nem Byte Rotieren kann, einfach in msil gebaut und passt.

Code:
.assembly BitShifter {}
.module BitShifter.dll
.namespace Converter
{
.class public auto ansi BitShifter extends [mscorlib]System.Object {

.method public static uint8 RotateLeft(uint8 'value', uint32 count) cil managed
{

	ldarg.0
	ldarg.1
	ldc.i4.s 7
	and
	shl
	ldarg.0
	ldc.i4.s 8
	ldarg.1
	sub
	ldc.i4.s 7
	and
	shr.un
	or
	ret
}

.method public static uint8 RotateRight(uint8 'value', uint32 count) cil managed
{
	ldarg.0
	ldarg.1
	ldc.i4.s 7
	and
	shr.un
	ldarg.0
	ldc.i4.s 8
	ldarg.1
	sub
	ldc.i4.s 7
	and
	shl
	or
	ret
}
}
}
Entspricht ca folgendem c# code.
[Only registered and activated users can see links. Click Here To Register...]

compilieren wie immer mit
Quote:
ilasm source.il /dll /output=BitShifter.dll
Viel Spaß damit ;)