<!--
	Assembler Encoding for the Decrement Mnemonic
	Version: 1.0.0
	Date Created:  2007-05-01
	Last Modified: 2007-05-25

	Designed for Pentium and higher x86 Processors in 32bit mode protected mode
	Optimized for Size

	Done list:
	o US8-256,Boolean
	o EndRegs

	To Do:
	o ???
-->
<encoding procfamily="x86" bitdepth="32" proc="Pentium">
	<!-- ############################################################################################################ -->
	<!-- ############################################################################################################ -->
	<!-- ############################################################################################################ -->
	<!-- Decrement Mnemonic -->
	<mnemonic name="Decrement" type="Unary" option="Size">
		<!-- ********************************************************************************************************** -->
		<!-- Decrementing 8bit values -->
		<codetypeset param0="U/S8">
			<codeset param0="M" total="3" timev="2" endpipe="S">
				<line code="dec @0.U8" time="U 3" timev=" V3" comment="Decrement the value" />
			</codeset>

			<codeset param0="R" total="1" timev="0" endpipe="S">
				<line code="dec @0.U8" time="U 1" timev=" V1" comment="Decrement the value" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Decrementing 16bit values -->
		<codetypeset param0="U/S16">
			<codeset param0="M" total="4" totalv="3" endpipe="S">
				<line code="dec @0.U16" time="U 3+1" timev=" V3+1" comment="Decrement the value" />
			</codeset>

			<codeset param0="R" total="2" totalv="1" endpipe="S">
				<line code="dec @0.U16" time="U 1+1" timev=" V1+1" comment="Decrement the value" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Decrementing 24bit values -->
		<codetypeset param0="U/S24">
			<codeset param0="M" total="7" totalv="6" endpipe="U">
				<line code="sub @0.U16, 1"   time="U 3+1" timev=" V3+1" comment="Decrement the low 16 bits" />
				<line code="sbb @0.U8[2], 0" time="U!3"                 comment="Subtract with borrow from the upper byte" />
			</codeset>

			<codeset param0="R" param0type="U24" total="2" totalv="1" endpipe="U">
				<line code="dec @0.U32"           time="U 1" timev=" V1" comment="Decrement the full 32bit value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1" timev="U 1" comment="Clear the high byte" />
			</codeset>
			<codeset param0="R" param0type="S24" total="3" totalv="2" endpipe="U">
				<line code="dec @0.U32"    time="U 1" timev=" V1" comment="Decrement the full 32bit value" />
				<line code="shl @0.U32, 8" time="U!1"             comment="Shift to the high byte" />
				<line code="sar @0.U32, 8" time="U!1"             comment="SAR to sign extend" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Decrementing 32bit values -->
		<codetypeset param0="U/S32">
			<codeset param0="M" total="3" totalv="2" endpipe="S">
				<line code="dec @0.U32" time="U 3" timev=" V3" comment="Decrement the value" />
			</codeset>

			<codeset param0="R" total="1" totalv="0" endpipe="S">
				<line code="dec @0.U32" time="U 1" timev=" V1" comment="Decrement the value" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Decrementing 48bit values -->
		<codetypeset param0="U/S48">
			<codeset param0="M" total="7" totalv="6" endpipe="U">
				<line code="sub @0.U32, 1"    time="U 3"   timev=" V3" comment="Decrement the low 32 bits" />
				<line code="sbb @0.U16[2], 0" time="U!3+1"             comment="Subtract with borrow from the high 16 bits" />
			</codeset>

			<codeset param0="R" param0type="U48" total="3" totalv="2" endpipe="U">
				<line code="sub @0.U32, 1"         time="U 1" timev=" V1" comment="Decrement the low 32 bits" />
				<line code="sbb @0.U32[1], 0"      time="U!1"             comment="Subtract with borrow from the high 32 bits" />
				<line code="and @0.U32[1], 0FFFFh" time="U*1"             comment="Clear the high word" />
			</codeset>
			<codeset param0="R" param0type="S48" total="4" totalv="3" endpipe="U">
				<line code="sub @0.U32, 1"     time="U 1" timev=" V1" comment="Decrement the low 32 bits" />
				<line code="sbb @0.U32[1], 0"  time="U!1"             comment="Subtract with borrow from the high 32 bits" />
				<line code="shl @0.U32[1], 16" time="U!1"             comment="Shift to the high bytes" />
				<line code="sar @0.U32[1], 16" time="U!1"             comment="SAR to sign extend" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Decrementing 64bit values -->
		<codetypeset param0="U/S64">
			<codeset param0="M" total="6" totalv="5" endpipe="U">
				<line code="sub @0.U32, 1"    time="U 3" timev=" V3" comment="Decrement the low 32 bits" />
				<line code="sbb @0.U32[1], 0" time="!U3"             comment="Subtract with borrow from the high 32 bits" />
			</codeset>

			<codeset param0="R" total="2" totalv="1" endpipe="U">
				<line code="sub @0.U32, 1"    time="U 1" timev=" V1" comment="Decrement the low 32 bits" />
				<line code="sbb @0.U32[1], 0" time="U!1"             comment="Subtract with borrow from the high 32 bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Decrementing 128bit values -->
		<codetypeset param0="U/S128">
			<codeset param0="M" total="1+?" totalv="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 the value" />
				<line code="call Mnemonic_Dec_US128" time="!V1+?"             comment="Decrement the value" />
			</codeset>

			<codeset param0="R" total="4" totalv="3" endpipe="U">
				<line code="sub @0.U32, 1"    time="U 1" timev=" V1" comment="Decrement the low 32 bits" />
				<line code="sbb @0.U32[1], 0" time="U!1"             comment="Subtract with borrow from the second 32 bits" />
				<line code="sbb @0.U32[2], 0" time="U!1"             comment="Subtract with borrow from the third 32 bits" />
				<line code="sbb @0.U32[3], 0" time="U!1"             comment="Subtract with borrow from the high 32 bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Decrementing 256bit values -->
		<codetypeset param0="U/S256">
			<codeset param0="M" total="1+?" totalv="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 the value" />
				<line code="call Mnemonic_Dec_US256" time="!V1+?"             comment="Decrement the value" />
			</codeset>

			<codeset param0="R" total="8" totalv="7" endpipe="U">
				<line code="sub @0.U32, 1"    time="U 1" timev=" V1" comment="Decrement the low 32 bits" />
				<line code="sbb @0.U32[1], 0" time="U!1"             comment="Subtract with borrow from the second 32 bits" />
				<line code="sbb @0.U32[2], 0" time="U!1"             comment="Subtract with borrow from the third 32 bits" />
				<line code="sbb @0.U32[3], 0" time="U!1"             comment="Subtract with borrow from the fourth 32 bits" />
				<line code="sbb @0.U32[4], 0" time="U!1"             comment="Subtract with borrow from the fifth 32 bits" />
				<line code="sbb @0.U32[5], 0" time="U!1"             comment="Subtract with borrow from the sixth 32 bits" />
				<line code="sbb @0.U32[6], 0" time="U!1"             comment="Subtract with borrow from the seventh 32 bits" />
				<line code="sbb @0.U32[7], 0" time="U!1"             comment="Subtract with borrow from the high 32 bits" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Decrementing Boolean values -->
		<codetypeset param0="Boolean">
			<codeset param0="M" total="3" totalv="2" endpipe="S">
				<line code="xor @0.U8, 1" time="U 3" timev=" V3" comment="NOT the bit" />
			</codeset>

			<codeset param0="R" total="1" totalv="0" endpipe="S">
				<line code="xor @0.U8, 1" time="U 1" timev=" V1" comment="NOT the bit" />
			</codeset>
		</codetypeset>
	</mnemonic>
</encoding>
