<!--
	Assembler Encoding for the Complement Mnemonic
	Version: 1.0.0
	Date Created:  2007-04-29
	Last Modified: 2007-05-19

	Designed for Pentium and higher x86 Processors in 32bit mode protected mode
	Optimized for Size

	Done list:
	o U/S8-256,Boolean
-->
<encoding procfamily="x86" bitdepth="32" proc="P1">
	<!-- ############################################################################################################ -->
	<!-- ############################################################################################################ -->
	<!-- ############################################################################################################ -->
	<!-- Complement Mnemonic -->
	<mnemonic name="Complement" type="Unary" option="Size">
		<!-- ********************************************************************************************************** -->
		<!-- 8bit values -->
		<codetypeset param0="U/S8">
			<codeset param0="M" total="3" endpipe="V">
				<line code="not @0.U8" time="&#45;&#45;3" comment="NOT the value" />
			</codeset>

			<codeset param0="R" total="1" endpipe="V">
				<line code="not @0" time="&#45;&#45;1" comment="NOT the value" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 16bit values -->
		<codetypeset param0="U/S16">
			<codeset param0="M" total="4" endpipe="V">
				<line code="not @0.U16" time="&#45;&#45;3+1" comment="NOT the value" />
			</codeset>

			<codeset param0="R" total="2" endpipe="V">
				<line code="not @0.U16" time="&#45;&#45;1+1" comment="NOT the value" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 24bit values -->
		<codetypeset param0="U/S24">
			<codeset param0="M" total="7" endpipe="V">
				<line code="not @0.U16"   time="&#45;&#45;3+1" comment="NOT the low 16 bits" />
				<line code="not @0.U8[2]" time="&#45;&#45;3"   comment="NOT the high 8 bits" />
			</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="U24" total="1" endpipe="V">
				<line code="not @0.U32" time="&#45;&#45;1" comment="NOT the full register value (also switches the sign extension)" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 32bit values -->
		<codetypeset param0="U/S32">
			<codeset param0="M" total="3" endpipe="V">
				<line code="not @0.U32" time="&#45;&#45;3" comment="NOT the value" />
			</codeset>

			<codeset param0="R" total="1" endpipe="V">
				<line code="not @0.U32" time="&#45;&#45;1" comment="NOT the value" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 48bit values -->
		<codetypeset param0="U/S48">
			<codeset param0="M" total="7" endpipe="V">
				<line code="not @0.U32"    time="&#45;&#45;3"   comment="NOT the low 32 bits" />
				<line code="not @0.U16[2]" time="&#45;&#45;3+1" comment="NOT the high 16 bits" />
			</codeset>

			<codeset param0="R" param0type="U48" total="3" endpipe="V">
				<line code="not @0.U32"    time="&#45;&#45;1"   comment="NOT the low 32 bits" />
				<line code="not @0.U16[2]" time="&#45;&#45;1+1" comment="NOT the high 16 bits" />
			</codeset>
			<codeset param0="R" param0type="S48" total="3" endpipe="V">
				<line code="not @0.U32"    time="&#45;&#45;1"   comment="NOT the low 32 bits" />
				<line code="not @0.U32[1]" time="&#45;&#45;1+1" comment="NOT the high 32 bits (also switches the sign extension)" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 64bit values -->
		<codetypeset param0="U/S64">
			<codeset param0="M" total="6" endpipe="V">
				<line code="not @0.U32"    time="&#45;&#45;3" comment="NOT the low 32 bits" />
				<line code="not @0.U32[1]" time="&#45;&#45;3" comment="NOT the high 32 bits" />
			</codeset>

			<codeset param0="R" total="2" endpipe="V">
				<line code="not @0.U32"    time="&#45;&#45;1" comment="NOT the low 32 bits" />
				<line code="not @0.U32[1]" time="&#45;&#45;1" comment="NOT the high 32 bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 128bit values -->
		<codetypeset param0="U/S128">
			<codeset param0="M" total="1+?"
				lostregs="eax,edx" endregs="edx->@0.U8" endpipe="V">
				<line code="lea edx, @0.U8"                 time="U 1"   timev=" V1" comment="Get the address of our value" />
				<line code="call Mnemonic_Complement_US128" time="!V1+?"             comment="Complement the value" />
			</codeset>

			<codeset param0="R" total="4" endpipe="V">
				<line code="not @0.U32"    time="&#45;&#45;1" comment="NOT the low 32 bits" />
				<line code="not @0.U32[1]" time="&#45;&#45;1" comment="NOT the second 32 bits" />
				<line code="not @0.U32[2]" time="&#45;&#45;1" comment="NOT the third 32 bits" />
				<line code="not @0.U32[3]" time="&#45;&#45;1" comment="NOT the high 32 bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- 256bit values -->
		<codetypeset param0="U/S256">
			<codeset param0="M" total="1+?"
				lostregs="eax,edx" endregs="edx->@0.U8" endpipe="V">
				<line code="lea edx, @0.U8"                 time="U 1"   timev=" V1" comment="Get the address of our value" />
				<line code="call Mnemonic_Complement_US256" time="!V1+?"             comment="Complement the value" />
			</codeset>

			<codeset param0="R" total="8" endpipe="V">
				<line code="not @0.U32"    time="&#45;&#45;1" comment="NOT the low 32 bits" />
				<line code="not @0.U32[1]" time="&#45;&#45;1" comment="NOT the second 32 bits" />
				<line code="not @0.U32[2]" time="&#45;&#45;1" comment="NOT the third 32 bits" />
				<line code="not @0.U32[3]" time="&#45;&#45;1" comment="NOT the fourth 32 bits" />
				<line code="not @0.U32[4]" time="&#45;&#45;1" comment="NOT the fifth 32 bits" />
				<line code="not @0.U32[5]" time="&#45;&#45;1" comment="NOT the sixth 32 bits" />
				<line code="not @0.U32[6]" time="&#45;&#45;1" comment="NOT the seventh 32 bits" />
				<line code="not @0.U32[7]" time="&#45;&#45;1" comment="NOT the high 32 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>
