<!--
	Assembler Encoding for the Complement Mnemonic
	Version: 1.0.0
	Date Created:  2007-04-06
	Last Modified: 2007-05-19

	Designed for Pentium and higher x86 Processors in 32bit mode protected mode
	Optimized for speed

	Done list:
	o U/S8-256,Boolean
-->
<encoding procfamily="x86" bitdepth="32" proc="P1">
	<!-- ############################################################################################################ -->
	<!-- ############################################################################################################ -->
	<!-- ############################################################################################################ -->
	<!-- Complement Mnemonic -->
	<mnemonic name="Complement" type="Unary" option="Speed">
		<!-- ********************************************************************************************************** -->
		<!-- 8bit values -->
		<codetypeset param0="U/S8">
			<codeset param0="M" total="3" totalv="2" endpipe="S">
				<line code="xor @0, -1" time="U 3" timev=" V3" comment="Swap the value's bits" />
			</codeset>

			<codeset param0="R" total="1" totalv="0" endpipe="S">
				<line code="xor @0, -1" time="U 1" timev=" V1" comment="Swap the value's bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 16bit values -->
		<codetypeset param0="U/S16">
			<codeset param0="M" total="4" totalv="3" endpipe="S">
				<line code="xor @0, -1" time="U 3+1" timev=" V3+1" comment="Swap the value's bits" />
			</codeset>

			<codeset param0="R" total="2" totalv="1" endpipe="S">
				<line code="xor @0, -1" time="U 1+1" timev=" V1+1" comment="Swap the value's bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 24bit values -->
		<codetypeset param0="U/S24">
			<codeset param0="M" total="6" totalv="5"
				lostregs="al,dl" endregs="al=@0.U8[2],dl=@0.U8[1]" endpipe="U">
				<line code="mov al, @0.U8"    time="U 1" timev=" V1" comment="Get the first byte" />
				<line code="mov dl, @0.U8[1]" time="U*1" timev="U 1" comment="Get the second byte" />
				<line code="xor al, -1"       time=" V1"             comment="Swap the first byte's bits" />
				<line code="mov @0.U8, al"    time="U 1"             comment="Store the first byte" />
				<line code="xor dl, -1"       time=" V1"             comment="Swap the second byte's bits" />
				<line code="mov al, @0.U8[2]" time="U 1"             comment="Get the third byte" />
				<line code="mov @0.U8[1], dl" time="U*1"             comment="Store the second byte" />
				<line code="xor al, -1"       time=" V1"             comment="Swap the third byte's bits" />
				<line code="mov @0.U8[2], al" time="U 1"             comment="Store the third byte" />
			</codeset>

			<codeset param0="R" param0type="U24" total="1" totalv="0" endpipe="S">
				<line code="xor @0.U32, 0FFFFFFh" time="U 1" timev=" V1" comment="Swap the low 24 bits only" />
			</codeset>
			<codeset param0="R" param0type="S24" total="1" totalv="0" endpipe="S">
				<line code="xor @0.U32, -1" time="U 1" timev=" V1" comment="Swap all bits (this also switches the sign extension)" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 32bit values -->
		<codetypeset param0="U/S32">
			<codeset param0="M" total="3" totalv="2" endpipe="S">
				<line code="xor @0, -1" time="U 3" timev=" V3" comment="Swap the value's bits" />
			</codeset>

			<codeset param0="R" total="1" totalv="0" endpipe="S">
				<line code="xor @0, -1" time="U 1" timev=" V1" comment="Swap the value's bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 48bit values -->
		<codetypeset param0="U/S48">
			<codeset param0="M" total="6" totalv="6" endpipe="S">
				<line code="xor @0.U32, -1"    time="U 3"   timev=" V3"   comment="Swap the low dword's bits" />
				<line code="xor @0.U16[2], -1" time=" V3+1" timev="U 3+1" comment="Swap the high word's bits" />
			</codeset>

			<codeset param0="R" param0type="U48" total="2" totalv="1" endpipe="S">
				<line code="xor @0.U32, -1"        time="U 1" timev=" V1" comment="Swap the low dword's bits" />
				<line code="xor @0.U32[1], 0FFFFh" time=" V1" timev="U 1" comment="Swap the high word's bits" />
			</codeset>
			<codeset param0="R" param0type="S48" total="2" totalv="1" endpipe="S">
				<line code="xor @0.U32, -1"    time="U 1" timev=" V1" comment="Swap the low dword's bits" />
				<line code="xor @0.U32[1], -1" time=" V1" timev="U 1" comment="Swap the high dword's bits (this also switches the sign extension)" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 64bit values -->
		<codetypeset param0="U/S64">
			<codeset param0="M" total="3" totalv="3"
				lostregs="eax,edx" endregs="eax=@0.U32,edx=@0.U32[1]" endpipe="S">
				<line code="mov eax, @0.U32"    time="U 1" timev=" V1" comment="Get the low dword" />
				<line code="mov edx, @0.U32[1]" time=" V1" timev="U 1" comment="Get the high dword" />
				<line code="xor eax, -1"        time="U 1" timev=" V1" comment="Swap the low dword's bits" />
				<line code="xor edx, -1"        time=" V1" timev="U 1" comment="Swap the high dword's bits" />
				<line code="mov @0.U32, eax"    time="U 1" timev=" V1" comment="Store the low dword" />
				<line code="mov @0.U32[1], edx" time=" V1" timev="U 1" comment="Store the high dword" />
			</codeset>

			<codeset param0="R" total="1" totalv="1" endpipe="S">
				<line code="xor @0.U32, -1"    time="U 1" timev=" V1" comment="Swap the low dword's bits" />
				<line code="xor @0.U32[1], -1" time=" V1" timev="U 1" comment="Swap the high dword's bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 128bit values -->
		<codetypeset param0="U/S128">
			<codeset param0="M" total="6" totalv="6"
				lostregs="eax,edx" endregs="eax=@0.U32,edx=@0.U32[1]" endpipe="S">
				<line code="mov eax, @0.U32[2]" time="U 1" timev=" V1" comment="Get the third dword" />
				<line code="mov edx, @0.U32[3]" time=" V1" timev="U 1" comment="Get the high dword" />
				<line code="xor eax, -1"        time="U 1" timev=" V1" comment="Swap the third dword's bits" />
				<line code="xor edx, -1"        time=" V1" timev="U 1" comment="Swap the high dword's bits" />
				<line code="mov @0.U32[2], eax" time="U 1" timev=" V1" comment="Store the third dword" />
				<line code="mov @0.U32[3], edx" time=" V1" timev="U 1" comment="Store the high dword" />

				<line code="mov eax, @0.U32"    time="U 1" timev=" V1" comment="Get the low dword" />
				<line code="mov edx, @0.U32[1]" time=" V1" timev="U 1" comment="Get the second dword" />
				<line code="xor eax, -1"        time="U 1" timev=" V1" comment="Swap the low dword's bits" />
				<line code="xor edx, -1"        time=" V1" timev="U 1" comment="Swap the second dword's bits" />
				<line code="mov @0.U32, eax"    time="U 1" timev=" V1" comment="Store the low dword" />
				<line code="mov @0.U32[1], edx" time=" V1" timev="U 1" comment="Store the second dword" />
			</codeset>

			<codeset param0="R" total="2" totalv="2" endpipe="S">
				<line code="xor @0.U32, -1"    time="U 1" timev=" V1" comment="Swap the low dword's bits" />
				<line code="xor @0.U32[1], -1" time=" V1" timev="U 1" comment="Swap the second dword's bits" />
				<line code="xor @0.U32[2], -1" time="U 1" timev=" V1" comment="Swap the third dword's bits" />
				<line code="xor @0.U32[3], -1" time=" V1" timev="U 1" comment="Swap the high dword's bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 256bit values -->
		<codetypeset param0="U/S256">
			<codeset param0="M" total="12" totalv="12"
				lostregs="eax,edx" endregs="eax=@0.U32,edx=@0.U32[1]" endpipe="S">
				<line code="mov eax, @0.U32[6]" time="U 1" timev=" V1" comment="Get the seventh dword" />
				<line code="mov edx, @0.U32[7]" time=" V1" timev="U 1" comment="Get the high dword" />
				<line code="xor eax, -1"        time="U 1" timev=" V1" comment="Swap the seventh dword's bits" />
				<line code="xor edx, -1"        time=" V1" timev="U 1" comment="Swap the high dword's bits" />
				<line code="mov @0.U32[6], eax" time="U 1" timev=" V1" comment="Store the seventh dword" />
				<line code="mov @0.U32[7], edx" time=" V1" timev="U 1" comment="Store the high dword" />

				<line code="mov eax, @0.U32[4]" time="U 1" timev=" V1" comment="Get the fifth dword" />
				<line code="mov edx, @0.U32[5]" time=" V1" timev="U 1" comment="Get the sixth dword" />
				<line code="xor eax, -1"        time="U 1" timev=" V1" comment="Swap the fifth dword's bits" />
				<line code="xor edx, -1"        time=" V1" timev="U 1" comment="Swap the sixth dword's bits" />
				<line code="mov @0.U32[4], eax" time="U 1" timev=" V1" comment="Store the fifth dword" />
				<line code="mov @0.U32[5], edx" time=" V1" timev="U 1" comment="Store the sixth dword" />

				<line code="mov eax, @0.U32[2]" time="U 1" timev=" V1" comment="Get the third dword" />
				<line code="mov edx, @0.U32[3]" time=" V1" timev="U 1" comment="Get the fourth dword" />
				<line code="xor eax, -1"        time="U 1" timev=" V1" comment="Swap the third dword's bits" />
				<line code="xor edx, -1"        time=" V1" timev="U 1" comment="Swap the fourth dword's bits" />
				<line code="mov @0.U32[2], eax" time="U 1" timev=" V1" comment="Store the third dword" />
				<line code="mov @0.U32[3], edx" time=" V1" timev="U 1" comment="Store the fourth dword" />

				<line code="mov eax, @0.U32"    time="U 1" timev=" V1" comment="Get the low dword" />
				<line code="mov edx, @0.U32[1]" time=" V1" timev="U 1" comment="Get the second dword" />
				<line code="xor eax, -1"        time="U 1" timev=" V1" comment="Swap the low dword's bits" />
				<line code="xor edx, -1"        time=" V1" timev="U 1" comment="Swap the second dword's bits" />
				<line code="mov @0.U32, eax"    time="U 1" timev=" V1" comment="Store the low dword" />
				<line code="mov @0.U32[1], edx" time=" V1" timev="U 1" comment="Store the second dword" />
			</codeset>

			<codeset param0="R" total="4" totalv="4" endpipe="S">
				<line code="xor @0.U32, -1"    time="U 1" timev=" V1" comment="Swap the low dword's bits" />
				<line code="xor @0.U32[1], -1" time=" V1" timev="U 1" comment="Swap the second dword's bits" />
				<line code="xor @0.U32[2], -1" time="U 1" timev=" V1" comment="Swap the third dword's bits" />
				<line code="xor @0.U32[3], -1" time=" V1" timev="U 1" comment="Swap the fourth dword's bits" />
				<line code="xor @0.U32[4], -1" time="U 1" timev=" V1" comment="Swap the fifth dword's bits" />
				<line code="xor @0.U32[5], -1" time=" V1" timev="U 1" comment="Swap the sixth dword's bits" />
				<line code="xor @0.U32[6], -1" time="U 1" timev=" V1" comment="Swap the seventh dword's bits" />
				<line code="xor @0.U32[7], -1" time=" V1" timev="U 1" comment="Swap the high dword's bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Boolean -->
		<codetypeset param0="Boolean">
			<codeset param0="M" total="3" totalv="2" endpipe="S">
				<line code="xor @0, 1" time="U 3" timev=" V3" comment="Swap the bit" />
			</codeset>

			<codeset param0="R" total="1" totalv="0" endpipe="S">
				<line code="xor @0, 1" time="U 1" timev=" V1" comment="Swap the bit" />
			</codeset>
		</codetypeset>
	</mnemonic>
</encoding>
