<!--
	Assembler Encoding for the Subtract Mnemonic
	Version: 1.0.0
	Date Created:  2007-05-03
	Last Modified: 2007-06-17

	Designed for Pentium and higher x86 Processors in 32bit mode protected mode
	This DOES NOT set carry properly for future carry tests
	Optimized for Size

	Done list:
	o U/S8-256, Boolean added to U/S8-32, Boolean
	o EndRegs

	To Do:
	o Everything Else
-->
<encoding procfamily="x86" bitdepth="32" proc="Pentium">
	<!-- ############################################################################################################ -->
	<!-- ############################################################################################################ -->
	<!-- ############################################################################################################ -->
	<!-- Subtract Mnemonic -->
	<mnemonic name="Subtract" type="Assign" option="Size">
		<!-- ********************************************************************************************************** -->
		<!-- Subtracting FROM 8bit values -->

		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 8-256bit -->
		<codetypeset param0="U/S8" param1="U/S8-256">
			<codeset param0="M" param1="M" total="4" totalv="3"
				lostregs="al" endregs="al=@1.U8" endpipe="U">
				<line code="mov al, @1.U8" time="U 1" timev=" V1" comment="Get the value to subtract" />
				<line code="sub @0.U8, al" time="U*3" timev="U 3" comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="R" total="3" totalv="2" endpipe="S">
				<line code="sub @0.U8, @1.U8" time="U 3" timev=" V3" comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="I" total="3" endpipe="V">
				<line code="sub @0.U8, @1.U8" time="&#45;&#45;3" comment="Subtract from the value (Assume it's not pairable)" />
			</codeset>

			<codeset param0="R" param1="M" total="2" totalv="1" endpipe="S">
				<line code="sub @0.U8, @1.U8" time="U 2" timev=" V2" comment="Subtract from the value" />
			</codeset>
			<codeset param0="R" param1="R,I" total="1" totalv="0" endpipe="S">
				<line code="sub @0.U8, @1.U8" time="U 1" timev=" V1" comment="Subtract from the value" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With Boolean -->
		<codetypeset param0="U/S8" param1="Boolean">
			<!-- 1/0 Version -->
			<codeset param0="M" param1="M" total="4" totalv="3"
				lostregs="al" endregs="al=@1.U8" endpipe="U">
				<line code="mov al, @1.U8" time="U 1" timev=" V1" comment="Get the value to subtract" />
				<line code="sub @0.U8, al" time="U*3" timev="U 3" comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="R" total="3" totalv="2" endpipe="S">
				<line code="sub @0.U8, @1.U8" time="U 3" timev=" V3" comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M" total="2" totalv="1" endpipe="S">
				<line code="sub @0.U8, @1.U8" time="U 2" timev=" V2" comment="Subtract from the value" />
			</codeset>
			<codeset param0="R" param1="R" total="1" totalv="0" endpipe="S">
				<line code="sub @0.U8, @1.U8" time="U 1" timev=" V1" comment="Subtract from the value" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Subtracting FROM 16bit values -->

		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 8bit -->

		<!-- ====================================================================================== -->
		<!-- With U8 to U/S16 -->
		<codetypeset param0="U/S16" param1="U8">
			<codeset param0="M" param1="M,R" total="7"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U16, ax"  time="U 3+1"       comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M" total="3" totalv="2" endpipe="U">
				<line code="sub @0.U8, @1.U8" time="U 2" timev=" V2" comment="Subtract from the low byte of the value" />
				<line code="sbb @0.U8[1], 0"  time="U!1"             comment="Subtract with borrow from the high byte" />
			</codeset>
			<codeset param0="R" param1="R" total="2" totalv="1" endpipe="U">
				<line code="sub @0.U8, @1.U8" time="U 1" timev=" V1" comment="Subtract from the low byte of the value" />
				<line code="sbb @0.U8[1], 0"  time="U!1"             comment="Subtract with borrow from the high byte" />
			</codeset>
		</codetypeset>


		<!-- ====================================================================================== -->
		<!-- With S8 to U/S16 -->
		<codetypeset param0="U/S16" param1="S8">
			<codeset param0="M" param1="M,R" total="7"
				lostregs="eax" endregs="eax=@1.S8" endpipe="U">
				<line code="movsx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U16, ax"   time="U 3+1"       comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M,R" total="4"
				lostregs="eax" endregs="eax=@1.S8" endpipe="U">
				<line code="movsx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"  time="U 1"         comment="Subtract from the full register value" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 16-24bit -->
		<codetypeset param0="U/S16" param1="U/S16-24">
			<codeset param0="M" param1="M" total="6" totalv="5"
				lostregs="ax" endregs="ax=@1.U16" endpipe="U">
				<line code="mov ax, @1.U16" time="U 1+1" timev=" V1+1" comment="Get the value to subtract" />
				<line code="sub @0.U16, ax" time="U*3+1" timev="U 3+1" comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="R" total="4" totalv="3" endpipe="S">
				<line code="sub @0.U16, @1.U16" time="U 3+1" timev=" V3+1" comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="I" total="4" endpipe="V">
				<line code="sub @0.U16, @1.U16" time="&#45;&#45;3+1" comment="Subtract from the value (Assume it's not pairable)" />
			</codeset>

			<codeset param0="R" param1="M" total="3" totalv="2" endpipe="S">
				<line code="sub @0.U16, @1.U16" time="U 2+1" timev=" V2+1" comment="Subtract from the value" />
			</codeset>
			<codeset param0="R" param1="R" total="1" totalv="0" endpipe="S">
				<line code="sub @0.U32, @1.U32" time="U 1" timev=" V1+1" comment="Subtract from the value" />
			</codeset>
			<codeset param0="R" param1="I" total="2" totalv="1" endpipe="S">
				<line code="sub @0.U16, @1.U16" time="U 1+1" timev=" V1+1" comment="Subtract from the value" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 32-256bit -->
		<codetypeset param0="U/S16" param1="U/S32-256">
			<codeset param0="M" param1="M" total="5" totalv="4"
				lostregs="eax" endregs="eax=@1.U32" endpipe="U">
				<line code="mov eax, @1.U32" time="U 1"   timev=" V1"   comment="Get the value to subtract" />
				<line code="sub @0.U16, ax"  time="U*3+1" timev="U 3+1" comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="R" total="4" totalv="3" endpipe="S">
				<line code="sub @0.U16, @1.U16" time="U 3+1" timev=" V3+1" comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M" total="2" totalv="1" endpipe="S">
				<line code="sub @0.U32, @1.U32" time="U 2" timev=" V2" comment="Subtract from the full register value" />
			</codeset>
			<codeset param0="R" param1="R" total="1" totalv="0" endpipe="S">
				<line code="sub @0.U32, @1.U32" time="U 1" timev=" V1" comment="Subtract from the full register value" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With Boolean -->
		<codetypeset param0="U/S16" param1="Boolean">
			<!-- 1/0 Version -->
			<codeset param0="M" param1="M,R" total="7"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U16, ax"   time="U 3+1"       comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M" total="3" totalv="2" endpipe="U">
				<line code="sub @0.U8, @1.U8" time="U 2" timev=" V2" comment="Subtract from the low byte of the value" />
				<line code="sbb @0.U8, 0"     time="U!1"             comment="Subtract with borrow from the high byte" />
			</codeset>
			<codeset param0="R" param1="R" total="2" totalv="1" endpipe="U">
				<line code="sub @0.U8, @1.U8" time="U 1" timev=" V1" comment="Subtract from the low byte of the value" />
				<line code="sbb @0.U8, 0"     time="U!1"             comment="Subtract with borrow from the high byte" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Subtracting FROM 24bit values -->

		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 8bit -->

		<!-- ====================================================================================== -->
		<!-- With U8 to U/S24 -->
		<codetypeset param0="U/S24" param1="U8">
			<codeset param0="M" param1="M" total="10"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8" time="&#45;&#45;3"   comment="Get the value to subtract" />
				<line code="sub @0.U16, ax"   time="U 3+1"         comment="Subtract from the low 16 bits of the value" />
				<line code="sbb @0.U8[2], 0"  time="U!3"           comment="Subtract with borrow from the high byte of the value" />
			</codeset>
			<codeset param0="M" param1="R" total="9" totalv="8" endpipe="U">
				<line code="sub @0.U8, @1.U8" time="U 3" timev=" V3" comment="Subtract from the low byte of the value" />
				<line code="sbb @0.U8[1], 0"  time="U!3"             comment="Subtract with borrow from the middle byte of the value" />
				<line code="sbb @0.U8[2], 0"  time="U!3"             comment="Subtract with borrow from the high byte of the value" />
			</codeset>

			<codeset param0="R" param1="M,R" param0type="U24" total="5"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8"     time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"      time="U 1"         comment="Subtract from the value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1"         comment="Clear the high byte" />
			</codeset>
			<codeset param0="R" param1="M,R" param0type="S24" total="6"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"  time="U 1"         comment="Subtract from the value" />
				<line code="shl @0.U32, 8"    time="U!1"         comment="Move to the high byte" />
				<line code="sar @0.U32, 8"    time="U!1"         comment="SAR to sign extend" />
			</codeset>
		</codetypeset>

		<!-- ====================================================================================== -->
		<!-- With S8 to U/S24 -->
		<codetypeset param0="U/S24" param1="S8">
			<codeset param0="M" param1="M,R" total="10"
				lostregs="eax" endregs="eax=@1.S8" endpipe="U">
				<line code="movsx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U16, ax"   time="U*3+1"       comment="Subtract from the low 16 bits of the value" />
				<line code="sbb @0.U8[2], ah" time="U!3"         comment="Subtract with borrow from the high byte of the value" />
			</codeset>

			<codeset param0="R" param1="M,R" param0type="U24" total="5"
				lostregs="eax" endregs="eax=@1.S8" endpipe="U">
				<line code="movsx eax, @1.U8"     time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"      time="U 1"         comment="Subtract from the value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1"         comment="Clear the high byte" />
			</codeset>
			<codeset param0="R" param1="M,R" param0type="S24" total="6"
				lostregs="eax" endregs="eax=@1.S8" endpipe="U">
				<line code="movsx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"  time="U 1"         comment="Subtract from the value" />
				<line code="shl @0.U32, 8"    time="U!1"         comment="Move to the high byte" />
				<line code="sar @0.U32, 8"    time="U!1"         comment="SAR to sign extend" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 16bit -->

		<!-- ====================================================================================== -->
		<!-- With U16 to U/S24 -->
		<codetypeset param0="U/S24" param1="U16">
			<codeset param0="M" param1="M" total="9" totalv="8"
				lostregs="ax" endregs="ax=@1.U16" endpipe="U">
				<line code="mov ax, @1.U16"  time="U 1+1" timev=" V1+1" comment="Get the value to subtract" />
				<line code="sub @0.U16, ax"  time="U*3+1" timev="U 3+1" comment="Subtract from the low 16 bits" />
				<line code="sbb @0.U8[2], 0" time="U!3"                 comment="Subtract with borrow from the high byte" />
			</codeset>
			<codeset param0="M" param1="R" total="7" totalv="6" endpipe="U">
				<line code="sub @0.U16, @1.U16" time="U 3+1" timev=" V3+1" comment="Subtract from the low 16 bits" />
				<line code="sbb @0.U8[2], 0"    time="U!3"                 comment="Subtract with borrow from the high byte" />
			</codeset>

			<codeset param0="R" param1="M,R" param0type="U24" total="5"
				lostregs="eax" endregs="eax=@1.U16" endpipe="U">
				<line code="movzx eax, @1.U16"    time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"      time="U 1"         comment="Subtract from the full register value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1"         comment="Clear out the high byte" />
			</codeset>
			<codeset param0="R" param1="M,R" param0type="S24" total="6"
				lostregs="eax" endregs="eax=@1.U16" endpipe="U">
				<line code="movzx eax, @1.U16" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"   time="U 1"         comment="Subtract from the full register value" />
				<line code="shl @0.U32, 8"     time="U!1"         comment="Move to the high byte" />
				<line code="sar @0.U32, 8"     time="U!1"         comment="SAR to sign extend" />
			</codeset>
		</codetypeset>

		<!-- ====================================================================================== -->
		<!-- With S16 to U/S24 -->
		<codetypeset param0="U/S24" param1="S16">
			<codeset param0="M" param1="M,R" total="3+?" totalv="2+?"
				lostregs="eax,edx" endregs="edx->@0.U8" endpipe="V">
				<line code="lea edx, @0.U8"                    time="U 1"   timev=" V1"   comment="Point to our value" />
				<line code="mov ax, @1.U16"                    time=" V1+1" timev="U 1+1" comment="Get the value to subtract" />
				<ilne code="call Mnemonic_Subtract_US24AndS16" time="!V1+?"               comment="Get our value" />
			</codeset>

			<codeset param0="R" param1="M" param0type="U24" total="5"
				lostregs="eax" endregs="eax=@1.S16" endpipe="U">
				<line code="movsx eax, @1.U16"    time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"      time="U 1"         comment="Subtract from the full register value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1"         comment="Clear the high byte" />
			</codeset>
			<codeset param0="R" param1="M" param0type="S24" total="6"
				lostregs="eax" endregs="eax=@1.S16" endpipe="U">
				<line code="movsx eax, @1.U16" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"   time="U 1"         comment="Subtract from the full register value" />
				<line code="shl @0.U32, 8"     time="U!1"         comment="Move to the high byte" />
				<line code="sar @0.U32, 8"     time="U!1"         comment="SAR to sign extend" />
			</codeset>
			<codeset param0="R" param1="R" param0type="U24" total="4" endpipe="U">
				<line code="shl @1.U32, 16"       time="U!1" comment="Shift the value to the top bytes" />
				<line code="sar @1.U32, 16"       time="U!1" comment="SAR to sign extend" />
				<line code="sub @0.U32, @1.U32"   time="U*1" comment="Subtract from the full register value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1" comment="Clear the high byte" />
			</codeset>
			<codeset param0="R" param1="R" param0type="S24" total="5" endpipe="U">
				<line code="shl @1.U32, 16"     time="U!1" comment="Shift the value to the top bytes" />
				<line code="sar @1.U32, 16"     time="U!1" comment="SAR to sign extend" />
				<line code="sub @0.U32, @1.U32" time="U*1" comment="Subtract from the full register value" />
				<line code="shl @0.U32, 8"      time="U!1" comment="Move to the high byte" />
				<line code="sar @0.U32, 8"      time="U!1" comment="SAR to sign extend" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 24bit -->
		<codetypeset param0="U/S24" param1="U/S24">
			<codeset param0="M" param1="M" total="4+?" totalv="3+?"
				lostregs="eax,edx" endregs="edx->@0.U8" endpipe="V">
				<line code="mov ah, @1.U8[2]"                       time="U 1"   timev="V 1" comment="Get the high byte of the value to subtract" />
				<line code="shl eax, 8"                             time="U!1"               comment="Shift it into position" />
				<line code="lea edx, @0.U8"                         time=" V1"               comment="Point to our value" />
				<line code="mov ax, @1.U16"                         time="U 1+1"             comment="Get the low 16 bits of the value to subtract" />
				<line code="call Mnemonic_Subtract_US24AndUS24Plus" time="!V1+?"             comment="Subtract" />
			</codeset>
			<codeset param0="M" param1="R" total="2+?" totalv="1+?"
				lostregs="eax,edx" endregs="edx->@0.U8" endpipe="V">
				<line code="mov eax, @1.U32"                        time="U 1"   timev="V 1" comment="Get the full register value" />
				<line code="lea edx, @0.U8"                         time=" V1"   timev="U 1" comment="Point to our value" />
				<line code="call Mnemonic_Subtract_US24AndUS24Plus" time="!V1+?"             comment="Subtract" />
			</codeset>
			<codeset param0="M" param1="I" total="7" endpipe="V">
				<line code="sub @0.U16, @1.U16"  time="&#45;&#45;3+1" comment="Subtract the low 16 bits (assume not pipable)" />
				<line code="sbb @0.U8[2], @1.U8" time="&#45;&#45;3"   comment="Subtract the high 8 bits (assume not pipable)" />
			</codeset>

			<codeset param0="R" param1="M" param0type="U24" total="6" totalv="5"
				lostregs="eax" endregs="ax=@1.U16" endpipe="U">
				<line code="mov ah, @1.U8[2]"     time="U 1"   timev=" V1" comment="Get the high byte" />
				<line code="shl eax, 8"           time="U!1"               comment="Shift it into position" />
				<line code="mov ax, @1.U16"       time="U*1+1"             comment="Get the low 16 bits" />
				<line code="sub @0.U32, eax"      time="U*1"               comment="Subtract from the full register value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1"               comment="Clear the high byte" />
			</codeset>
			<codeset param0="R" param1="M" param0type="S24" total="7" totalv="6"
				lostregs="eax" endregs="ax=@1.U16" endpipe="U">
				<line code="mov ah, @1.U8[2]" time="U 1"   timev=" V1" comment="Get the high byte" />
				<line code="shl eax, 8"       time="U!1"               comment="Shift it into position" />
				<line code="mov ax, @1.U16"   time="U*1+1"             comment="Get the low 16 bits" />
				<line code="sub @0.U32, eax"  time="U*1"               comment="Subtract from the full register value" />
				<line code="shl @0.U32, 8"    time="U!1"               comment="Move to the high byte" />
				<line code="sar @0.U32, 8"    time="U!1"               comment="SAR to sign extend" />
			</codeset>
			<codeset param0="R" param1="R,I" param0type="U24" total="2" totalv="1" endpipe="U">
				<line code="sub @0.U32, @1.U32"   time="U 1" timev=" V1" comment="Subtract from the full register value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1" timev="U 1" comment="Clear the high byte" />
			</codeset>
			<codeset param0="R" param1="R,I" param0type="S24" total="3" totalv="2" endpipe="U">
				<line code="sub @0.U32, @1.U32" time="U 1" timev=" V1" comment="Subtract from the full register value" />
				<line code="shl @0.U32, 8"      time="U!1"             comment="Move to the high byte" />
				<line code="sar @0.U32, 8"      time="U!1"             comment="SAR to sign extend" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 32-256bit -->
		<codetypeset param0="U/S24" param1="U/S32-256">
			<codeset param0="M" param1="M,R" total="2+?" totalv="1+?"
				lostregs="eax,edx" endregs="edx->@0.U8" endpipe="V">
				<line code="mov eax, @1.U32"                        time="U 1"   timev="V 1" comment="Get the full register value" />
				<line code="lea edx, @0.U8"                         time=" V1"   timev="U 1" comment="Point to our value" />
				<line code="call Mnemonic_Subtract_US24AndUS24Plus" time="!V1+?"             comment="Subtract" />
			</codeset>

			<codeset param0="R" param1="M" param0type="U24" total="3" totalv="2" endpipe="U">
				<line code="sub @0.U32, @1.U32"   time="U 2" timev=" V2" comment="Subtract from the full register value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1" timev="U 1" comment="Clear the high byte" />
			</codeset>
			<codeset param0="R" param1="M" param0type="S24" total="4" totalv="3" endpipe="U">
				<line code="sub @0.U32, @1.U32" time="U 2" timev=" V2" comment="Subtract from the full register value" />
				<line code="shl @0.U32, 8"      time="U!1"             comment="Move to the high byte" />
				<line code="sar @0.U32, 8"      time="U!1"             comment="SAR to sign extend" />
			</codeset>
			<codeset param0="R" param1="R" param0type="U24" total="2" totalv="1" endpipe="U">
				<line code="sub @0.U32, @1.U32"   time="U 1" timev=" V1" comment="Subtract from the full register value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1" timev="U 1" comment="Clear the high byte" />
			</codeset>
			<codeset param0="R" param1="R" param0type="S24" total="3" totalv="2" endpipe="U">
				<line code="sub @0.U32, @1.U32" time="U 1" timev=" V1" comment="Subtract from the full register value" />
				<line code="shl @0.U32, 8"      time="U!1"             comment="Move to the high byte" />
				<line code="sar @0.U32, 8"      time="U!1"             comment="SAR to sign extend" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With Boolean -->
		<codetypeset param0="U/S24" param1="Boolean">
			<!-- 1/0 Version -->
			<codeset param0="M" param1="M" total="10" totalv="9"
				lostregs="al" endregs="al=@1.U8" endpipe="U">
				<line code="mov al, @1.U8"   time="U 1" timev=" V1" comment="Get the value to subtract" />
				<line code="sub @0.U8, al"   time="U*3" timev="U 3" comment="Subtract from the low byte of the value" />
				<line code="sbb @0.U8[1], 0" time="U!3"             comment="Subtract with borrow from the middle byte of the value" />
				<line code="sbb @0.U8[2], 0" time="U!3"             comment="Subtract with borrow from the high byte of the value" />
			</codeset>
			<codeset param0="M" param1="R" total="9" totalv="8" endpipe="U">
				<line code="sub @0.U8, @1.U8" time="U 3" timev=" V3" comment="Subtract from the low byte of the value" />
				<line code="sbb @0.U8[1], 0"  time="U!3"             comment="Subtract with borrow from the middle byte of the value" />
				<line code="sbb @0.U8[2], 0"  time="U!3"             comment="Subtract with borrow from the high byte of the value" />
			</codeset>

			<codeset param0="R" param1="M,R" param0type="U24" total="5"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8"     time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"      time="U 1"         comment="Subtract from the value" />
				<line code="and @0.U32, 0FFFFFFh" time="U*1"         comment="Clear the high byte" />
			</codeset>
			<codeset param0="R" param1="M,R" param0type="S24" total="6"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"  time="U 1"         comment="Subtract from the value" />
				<line code="shl @0.U32, 8"    time="U!1"         comment="Move to the high byte" />
				<line code="sar @0.U32, 8"    time="U!1"         comment="SAR to sign extend" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Subtracting FROM 32bit values -->

		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 8bit -->

		<!-- ====================================================================================== -->
		<!-- With U8 to U/S32 -->
		<codetypeset param0="U/S32" param1="U8">
			<codeset param0="M" param1="M,R" total="6"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"  time="U 3"         comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M,R" total="4"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"  time="U 1"         comment="Subtract from the value" />
			</codeset>
		</codetypeset>

		<!-- ====================================================================================== -->
		<!-- With S8 to U/S32 -->
		<codetypeset param0="U/S32" param1="S8">
			<codeset param0="M" param1="M,R" total="6"
				lostregs="eax" endregs="eax=@1.S8" endpipe="U">
				<line code="movsx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"  time="U 3"         comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M,R" total="4"
				lostregs="eax" endregs="eax=@1.S8" endpipe="U">
				<line code="movsx eax, @1.U8" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"  time="U 1"         comment="Subtract from the value" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 16bit -->

		<!-- ====================================================================================== -->
		<!-- With U16 to U/S32 -->
		<codetypeset param0="U/S32" param1="U16">
			<codeset param0="M" param1="M" total="6"
				lostregs="eax" endregs="eax=@1.U16" endpipe="U">
				<line code="movzx eax, @1.U16" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"   time="U 3"         comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="R" total="4" totalv="3" endpipe="U">
				<line code="and @1.U32, 0FFFFh" time="U 1" timev=" V1" comment="Clear the high 16 bits" />
				<line code="sub @0.U32, @1.U32" time="U*3" timev="U 3" comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M" total="4"
				lostregs="eax" endregs="eax=@1.U16" endpipe="U">
				<line code="movzx eax, @1.U16" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"   time="U 1"         comment="Subtract from the value" />
			</codeset>
			<codeset param0="R" param1="R" total="2" totalv="1" endpipe="U">
				<line code="and @1.U32, 0FFFFh" time="U 1" timev=" V1" comment="Clear the high 16 bits" />
				<line code="sub @0.U32, @1.U32" time="U*1" timev="U 1" comment="Subtract from the value" />
			</codeset>
		</codetypeset>

		<!-- ====================================================================================== -->
		<!-- With S16 to U/S32 -->
		<codetypeset param0="U/S32" param1="S16">
			<codeset param0="M" param1="M" total="6"
				lostregs="eax" endregs="eax=@1.S16" endpipe="U">
				<line code="movsx eax, @1.U16" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax"   time="U 3"         comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="R" total="5" endpipe="U">
				<line code="shl @1.U16, 16"     time="U!1"                 comment="Shift it to the high 16 bits" />
				<line code="sar @1.U16, 16"     time="U!1"                 comment="SAR to sign extend" />
				<line code="sub @0.U32, @1.U32" time="U*3"                 comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M" total="4"
				lostregs="eax" endregs="eax=@1.S16" endpipe="U">
				<line code="movsx eax, @1.U16" time="&#45;&#45;3" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax "  time="U 1" comment="Subtract from the value" />
			</codeset>
			<codeset param0="R" param1="R" total="3" endpipe="U">
				<line code="shl @1.U16, 16"     time="U!1" comment="Shift it to the high 16 bits" />
				<line code="sar @1.U16, 16"     time="U!1" comment="SAR to sign extend" />
				<line code="sub @0.U32, @1.U32" time="U*1" comment="Subtract from the value" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 24bit -->
		<codetypeset param0="U/S32" param1="U/S24">
			<codeset param0="M" param1="M" param1type="U24" total="4+?" totalv="4+?"
				lostregs="eax,edx" endregs="eax=@1.U24,edx->@1.U8" endpipe="U">
				<line code="lea edx, @1.U8"       time="U 1"   timev=" V1" comment="Get a pointer to the value to subtract" />
				<line code="call General_ReadU24" time="!V1+?"             comment="Get the 24 bit value" />
				<line code="sub @0.U32, eax"      time="U 3"               comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="M" param1type="S24" total="4+?" totalv="4+?"
				lostregs="eax,edx" endregs="eax=@1.S24,edx->@1.U8" endpipe="U">
				<line code="lea edx, @1.U8"       time="U 1"   timev=" V1" comment="Get a pointer to the value to subtract" />
				<line code="call General_ReadS24" time="!V1+?"             comment="Get the 24 bit value" />
				<line code="sub @0.U32, eax"      time="U 3"               comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="R" total="3" totalv="2" endpipe="S">
				<line code="sub @0.U32, @1.U32" time="U 3" timev=" V3" comment="Subtract the full register from the value" />
			</codeset>

			<codeset param0="R" param1="M" param1type="U24" total="2+?" totalv="2+?"
				lostregs="eax,edx" endregs="eax=@1.U24,edx->@1.U8" endpipe="U">
				<line code="lea edx, @1.U8"       time="U 1"   timev=" V1" comment="Get a pointer to the value to subtract" />
				<line code="call General_ReadU24" time="!V1+?"             comment="Get the 24 bit value" />
				<line code="sub @0.U32, eax"      time="U 1"               comment="Subtract from the value" />
			</codeset>
			<codeset param0="R" param1="M" param1type="S24" total="2+?" totalv="2+?"
				lostregs="eax,edx" endregs="eax=@1.S24,edx->@1.U8" endpipe="U">
				<line code="lea edx, @1.U8"       time="U 1"   timev=" V1" comment="Get a pointer to the value to subtract" />
				<line code="call General_ReadS24" time="!V1+?"             comment="Get the 24 bit value" />
				<line code="sub @0.U32, eax"      time="U 1"               comment="Subtract from the value" />
			</codeset>
			<codeset param0="R" param1="R" total="1" totalv="0" endpipe="S">
				<line code="sub @0.U32, @1.U32" time="U 1" timev=" V1" comment="Subtract the full register from the value" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 32-256bit -->
		<codetypeset param0="U/S32" param1="U/S32-256">
			<codeset param0="M" param1="M" total="4" totalv="3"
				lostregs="eax" endregs="eax=@1.U32" endpipe="U">
				<line code="mov eax, @1.U32" time="U 1" timev=" V1" comment="Get the value to subtract" />
				<line code="sub @0.U32, eax" time="U*3" timev="U 3" comment="Subtract from the value" />
			</codeset>
			<codeset param0="M" param1="R,I" total="3" totalv="2" endpipe="S">
				<line code="sub @0.U32, @1.U32" time="U 3" timev=" V3" comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M" total="2" totalv="1" endpipe="S">
				<line code="sub @0.U32, @1.U32" time="U 2" timev=" V2" comment="Subtract from the value" />
			</codeset>
			<codeset param0="R" param1="R,I" total="1" totalv="0" endpipe="S">
				<line code="sub @0.U32, @1.U32" time="U 1" timev=" V1" comment="Subtract from the value" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With Boolean -->
		<codetypeset param0="U/S32" param1="Boolean">
			<!-- 1/0 Version -->
			<codeset param0="M" param1="M,R" total="6"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8" time="&#45;&#45;3" comment="Get the value" />
				<line code="sub @0.U32, eax"  time="U 3"         comment="Subtract from the value" />
			</codeset>

			<codeset param0="R" param1="M,R" total="4"
				lostregs="eax" endregs="eax=@1.U8" endpipe="U">
				<line code="movzx eax, @1.U8" time="&#45;&#45;3" comment="Get the value" />
				<line code="sub @0.U32, eax"  time="U 1"         comment="Subtract from the value" />
			</codeset>
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- Subtracting FROM Boolean -->

		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With 8-256bit -->
		<codetypeset param0="Boolean" param1="U/S8-256">
			<!-- 1/0 Version -->
			<codeset param0="M" param1="M,R" total="5" totalv="4"
				lostregs="al" endpipe="U">
				<line code="mov al, @1.U8" time="U 1" timev=" V1" comment="Get the low byte" />
				<line code="and al, 1"     time="U*1" timev="U 1" comment="Keep only the low bit" />
				<line code="xor @0.U8, al" time="U*3"             comment="Subtracting the bit is the same as XORing by it" />
			</codeset>
			<codeset param0="M" param1="V" total="4" totalv="3"
				lostregs="@1.U8" endpipe="U">
				<line code="and @1.U8, 1"     time="U 1" timev=" V1" comment="Keep only the low bit" />
				<line code="xor @0.U8, @1.U8" time="U*3" timev="U 3" comment="Subtracting the bit is the same as XORing by it" />
			</codeset>

			<codeset param0="R" param1="M,R" total="3" totalv="2"
				lostregs="al" endpipe="U">
				<line code="mov al, @1.U8" time="U 1" timev=" V1" comment="Get the low byte" />
				<line code="and al, 1"     time="U*1" timev="U 1" comment="Keep only the low bit" />
				<line code="xor @0.U8, al" time="U*1"             comment="Subtracting the bit is the same as XORing by it" />
			</codeset>
			<codeset param0="R" param1="V" total="2" totalv="1"
				lostregs="@1.U8" endpipe="U">
				<line code="and @1.U8, 1"     time="U 1" timev=" V1" comment="Keep only the low bit" />
				<line code="xor @0.U8, @1.U8" time="U*1" timev="U 1" comment="Subtracting the bit is the same as XORing by it" />
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- With Boolean -->
		<codetypeset param0="Boolean" param1="Boolean">
			<!-- 1/0 Version -->
			<codeset param0="M" param1="M" total="4" totalv="3"
				lostregs="al" endregs="al=@1.U8" endpipe="U">
				<line code="mov al, @1.U8" time="U 1" timev=" V1" comment="Get the value to subtract" />
				<line code="xor @0.U8, al" time="U*3" timev="U 3" comment="XOR with the value" />
			</codeset>
			<codeset param0="M" param1="R,I" total="3" totalv="2" endpipe="S">
				<line code="xor @0.U8, @1.U8" time="U 3" timev=" V3" comment="XOR with the value" />
			</codeset>

			<codeset param0="R" param1="M" total="2" totalv="1" endpipe="U">
				<line code="xor @0.U8, @1.U8" time="U 2" timev=" V2" comment="XOR with the value" />
			</codeset>
			<codeset param0="R" param1="R,I" total="1" totalv="0" endpipe="S">
				<line code="xor @0.U8, @1.U8" time="U 1" timev=" V1" comment="XOR with the value" />
			</codeset>
		</codetypeset>
	</mnemonic>
</encoding>
