<!--
	Assembler Encoding for the RotateRight Mnemonic
	Version: 1.0.0
	Date Created:  2007-05-12
	Last Modified: 2007-05-20

	Designed for Pentium and higher x86 Processors in 32bit mode protected mode
	Optimized for Size

	Notes:
	o Rotating by anything that is larger than 8bits will only use the lower 8bits.
		This is accurate for 8, 16, 32, 64, 128 and 256bit values, but not necessarily accurate for 24 and 48 bit values.
		We could add tests based on the data type modified, but this would significantly slow down the operation and may
		not be very worthwhile.
	o Rotating very large values (48+ bit) is not supported natively by the x86 processors, so we have to work around
		it

	Done list:
	o U/S8-256,Boolean to U/S8-32,Boolean

	To Do:
	o U/S8-256,Boolean to U/S48-256
-->
<encoding procfamily="x86" bitdepth="32" proc="Pentium">
	<!-- ############################################################################################################ -->
	<!-- ############################################################################################################ -->
	<!-- ############################################################################################################ -->
	<!-- RotateRight Mnemonic -->
	<mnemonic name="RotateRight" type="Assign" option="Size">
		<!-- ********************************************************************************************************** -->
		<!-- RotateRighting 8bit values -->

		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- From 8-256bit -->
		<codetypeset param0="U/S8" param1="U/S8-256">
			<codeset param0="M,R" param1="M,R" total="6" totalv="6" id="RORUS8-256ToUS8_MR_MR"
				lostregs="al" endregs="al=cl" endpipe="U">
				<line code="mov al, cl"    time="U 1" timev=" V1" comment="Save CL" />
				<line code="mov cl, @1.U8" time=" V1" timev="U 1" comment="Get the value to shift by" />
				<line code="ror @0.U8, cl" time="&#45;&#45;4"     comment="Rotate right" />
				<line code="mov cl, al"    time="U 1"             comment="Get CL back" />
			</codeset>
			<codeset param0="M" param1="I" total="3" endpipe="V">
				<line code="ror @0.U8, @1.U8" time="&#45;&#45;3" comment="Rotate right (assume not piped)" />
			</codeset>
			<codeset param0="R.U8=cl" param1="M,R" total="6" totalv="6" id="RORUS8-256ToUS8_Rcl_MR"
				lostregs="al" endregs="al=@0.U8" endpipe="U">
				<line code="mov al, cl"    time="U 1" timev=" V1" comment="Move CL to AL" />
				<line code="mov cl, @1.U8" time=" V1" timev="U 1" comment="Get the value to shift by" />
				<line code="ror al, cl"    time="&#45;&#45;4"     comment="Rotate right" />
				<line code="mov cl, al"    time="U 1"             comment="Store the result" />
			</codeset>
			<codeset param0="M,R" param1="R.U8=cl" total="4" id="RORUS8-256ToUS8_MR_Rcl" endpipe="V">
				<line code="ror @0.U8, cl" time="&#45;&#45;4" comment="Rotate right" />
			</codeset>

			<codeset param0="R" param1="I" total="1" endpipe="U">
				<line code="ror @0.U8, @1.U8" time="U!1" comment="Rotate right" />
			</codeset>

			<codeset param0="M,R" param1="I=0" total="0" endpipe="-">
				<!-- Do Nothing -->
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- From Boolean -->
		<codetypeset param0="U/S8" param1="Boolean">
			<codeset param0="M,R" param1="M,R" sameas="RORUS8-256ToUS8_MR_MR" />
			<codeset param0="R.U8=cl" param1="M,R" sameas="RORUS8-256ToUS8_Rcl_MR" />
			<codeset param0="M,R" param1="R.U8=cl" sameas="RORUS8-256ToUS8_MR_Rcl" />
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- RotateRighting 16bit values -->

		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- From 8-256bit -->
		<codetypeset param0="U/S16" param1="U/S8-256">
			<codeset param0="M,R" param1="M,R" total="7" totalv="7" id="RORUS8-256ToUS16_MR_MR"
				lostregs="al" endregs="al=cl" endpipe="U">
				<line code="mov al, cl"     time="U 1"   timev=" V1" comment="Save CL" />
				<line code="mov cl, @1.U8"  time=" V1"   timev="U 1" comment="Get the value to shift by" />
				<line code="ror @0.U16, cl" time="&#45;&#45;4+1"     comment="Rotate right" />
				<line code="mov cl, al"     time="U 1"               comment="Get CL back" />
			</codeset>
			<codeset param0="M" param1="I" total="4" endpipe="V">
				<line code="ror @0.U16, @1.U8" time="&#45;&#45;3+1" comment="Rotate right (assume not piped)" />
			</codeset>

			<codeset param0="R.U8=cl" param1="M,R" total="7" totalv="7" id="RORUS8-256ToUS16_Rcl_MR"
				lostregs="eax" endregs="eax=@0.U32" endpipe="U">
				<line code="mov eax, ecx"  time="U 1" timev=" V1" comment="Move ECX to EAX" />
				<line code="mov cl, @1.U8" time=" V1" timev="U 1" comment="Get the value to shift by" />
				<line code="ror ax, cl"    time="&#45;&#45;4+1"   comment="Rotate right" />
				<line code="mov ecx, eax"  time="U 1"             comment="Store it" />
			</codeset>
			<codeset param0="R" param1="I" total="2" totalv="2" endpipe="U">
				<line code="ror @0.U16, @1.U8" time="U!1+1" comment="Rotate right" />
			</codeset>

			<codeset param0="M,R" param1="R.U8=cl" total="5" id="RORUS8-256ToUS16_MR_Rcl" endpipe="V">
				<line code="ror @0.U16, cl" time="&#45;&#45;4+1" comment="Rotate right" />
			</codeset>
			<codeset param0="M,R" param1="I=0" total="0" endpipe="-">
				<!-- Do Nothing -->
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- From Boolean -->
		<codetypeset param0="U/S16" param1="Boolean">
			<codeset param0="M,R" param1="M,R" sameas="RORUS8-256ToUS16_MR_MR" />
			<codeset param0="R.U8=cl" param1="M,R" sameas="RORUS8-256ToUS16_Rcl_MR" />
			<codeset param0="M,R" param1="R.U8=cl" sameas="RORUS8-256ToUS16_MR_Rcl" />
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- RotateRighting 24bit values -->

		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- From 8-256bit -->
		<codetypeset param0="U/S24" param1="U/S8-256">
			<codeset param0="M" param1="M,R,I" total="2+?" totalv="1+?" id="RORUS8-256ToUS24_M_MRI"
				lostregs="eax,edx" endregs="edx->@0" endpipe="V">
				<line code="mov al, @1.U8"          time="U 1"   timev=" V1" comment="Get the value to shift by" />
				<line code="lea edx, @0.U8"         time=" V1"   timev="U 1" comment="Get the pointer to our value" />
				<line code="call Mnemonic_ROR_US24" time="!V1+?"             comment="Shift the value" />
			</codeset>

			<codeset param0="R" param1="M,R,I" param1type="U24" total="3+?" totalv="2+?" id="RORUS8-256ToU24_R_MRI"
				lostregs="eax,edx" endregs="eax=@0.U24" endpipe="U">
				<line code="mov al, @1.U8"           time="U 1" timev=" V1" comment="Get the value to shift by" />
				<line code="mov edx, @0.U32"         time=" V1" timev="U 1" comment="Get the full register value" />
				<line code="call Mnemonic_ROR_U24_R" time="!V1+?"           comment="Rotate the 24bit register value" />
				<line code="mov @0.U32, eax"         time="U 1"             comment="Store the full register value" />
			</codeset>
			<codeset param0="R" param1="M,R,I" param1type="S24" total="3+?" totalv="2+?" id="RORUS8-256ToS24_R_MRI"
				lostregs="eax,edx" endregs="eax=@0.S24" endpipe="U">
				<line code="mov al, @1.U8"           time="U 1" timev=" V1" comment="Get the value to shift by" />
				<line code="mov edx, @0.U32"         time=" V1" timev="U 1" comment="Get the full register value" />
				<line code="call Mnemonic_ROR_S24_R" time="!V1+?"           comment="Rotate the 24bit register value" />
				<line code="mov @0.U32, eax"         time="U 1"             comment="Store the full register value" />
			</codeset>

			<codeset param0="M,R" param1="I=0" total="0" endpipe="-">
				<!-- Do Nothing -->
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- From Boolean -->
		<codetypeset param0="U/S24" param1="Boolean">
			<codeset param0="M" param1="M,R" sameas="RORUS8-256ToUS24_M_MRI" />
			<codeset param0="R" param1="M,R" param0type="U24" sameas="RORUS8-256ToU24_R_MRI" />
			<codeset param0="R" param1="M,R" param0type="S24" sameas="RORUS8-256ToS24_R_MRI" />
		</codetypeset>


		<!-- ********************************************************************************************************** -->
		<!-- RotateRighting 32bit values -->

		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- From 8-256bit -->
		<codetypeset param0="U/S32" param1="U/S8-256">
			<codeset param0="M,R" param1="M,R" total="6" totalv="6" id="RORUS8-256ToUS32_MR_MR"
				lostregs="al" endregs="al=cl" endpipe="U">
				<line code="mov al, cl"     time="U 1" timev=" V1" comment="Save CL" />
				<line code="mov cl, @1.U8"  time=" V1" timev="U 1" comment="Get the value to shift by" />
				<line code="ror @0.U32, cl" time="&#45;&#45;4"     comment="Rotate right" />
				<line code="mov cl, al"     time="U 1"             comment="Get CL back" />
			</codeset>
			<codeset param0="M" param1="I" total="3" endpipe="V">
				<line code="ror @0.U32, @1.U8" time="&#45;&#45;3" comment="Rotate right (assume not piped)" />
			</codeset>

			<codeset param0="R.U8=cl" param1="M,R" total="6" totalv="6" id="RORUS8-256ToUS32_Rcl_MR"
				lostregs="eax" endregs="eax=@0.U32" endpipe="U">
				<line code="mov eax, ecx"  time="U 1" timev=" V1" comment="Move ECX to EAX" />
				<line code="mov cl, @1.U8" time=" V1" timev="U 1" comment="Get the value to shift by" />
				<line code="ror eax, cl"   time="&#45;&#45;4"     comment="Rotate right the full register value" />
				<line code="mov ecx, eax"  time="U 1"             comment="Store it" />
			</codeset>
			<codeset param0="M,R" param1="R.U8=cl" total="4" id="RORUS8-256ToUS32_MR_Rcl" endpipe="V">
				<line code="ror @0.U32, cl" time="&#45;&#45;4" comment="Rotate right" />
			</codeset>
			<codeset param0="R" param1="I" total="1" endpipe="U">
				<line code="ror @0.U32, @1.U8" time="U!1" comment="Rotate right" />
			</codeset>

			<codeset param0="M,R" param1="I=0" total="0" endpipe="-">
				<!-- Do Nothing -->
			</codeset>
		</codetypeset>


		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- From Boolean -->
		<codetypeset param0="U/S32" param1="Boolean">
			<codeset param0="M,R" param1="M,R" sameas="RORUS8-256ToUS32_MR_MR" />
			<codeset param0="R.U8=cl" param1="M,R" sameas="RORUS8-256ToUS32_Rcl_MR" />
			<codeset param0="M,R" param1="R.U8=cl" sameas="RORUS8-256ToUS32_MR_Rcl" />
		</codetypeset>



		<!-- ********************************************************************************************************** -->
		<!-- RotateRighting Boolean -->

		<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
		<!-- From Any -->
		<!-- Rotating a 1bit value by anything results in the 1bit value being unmodified! -->
		<codetypeset param0="Boolean" param1="Any" />
	</mnemonic>
</encoding>
