User:Syaghmour/Text Processing Instructions

Text Processing Instructions
SSE 4.2 adds four string text processing instructions,  ,   and. These instructions take three parameters,  an xmm register,   an xmm or a 128-bit memory location and   an 8-bit immediate control byte. These instructions will perform arithmetic comparison between the packed contents of  and. specifies the format of the input/output as well as the operation of two intermediate stages of processing. The results of stage 1 and stage 2 of intermediate processing will be referred to as  and   respectively. These instructions also provide additional information about the result through overload use of the arithmetic flags(, ,  ,  ,   and  ).

The instructions proceed in multiple steps:
 * 1)  and   are compared
 * 2) An aggregation operation is applied to the result of the comparison with the result flowing into
 * 3) An optional negation is performed with the result flowing into
 * 4) An output in the form of an index(in ) or a mask(in  ) is produced

IMM8 control byte description
IMM8 control byte is split into four group of bit fields that control the following settings:

  specifies the format of the 128-bit source data(  and  ):

  specifies the aggregation operation whose result will be placed in intermediate result 1, which we will refer to as. The size of  will depend on the format of the source data, 16-bit for packed bytes and 8-bit for packed words:



 specifies the polarity or the processing of , into intermediate result 2, which will be referred to as  :



 specifies the output selection, or how   will be processed into the output. For  and , the output is an index into the data currently referenced by  :



For  and , the output is a mask reflecting all the set bits in  :



 should be set to zero since it has no designed meaning.



The Four Instructions
, Packed Compare Implicit Length Strings, Return Index. Compares strings of implicit length and generates index in.

 Operands 

arg1 arg2 IMM8
 * XMM Register
 * XMM Register
 * Memory
 * 8-bit Immediate value

 Modified flags 


 * 1)  is reset if   is zero, set otherwise
 * 2)  is set if a null terminating character is found in , reset otherwise
 * 3)  is set if a null terminating character is found in , reset otherwise
 * 4)  is set to
 * 5)  is reset
 * 6)  is reset

Example

Expected output:

, Packed Compare Implicit Length Strings, Return Mask. Compares strings of implicit length and generates a mask stored in.

 Operands 

arg1 arg2 IMM8
 * XMM Register
 * XMM Register
 * Memory
 * 8-bit Immediate value

 Modified flags 
 * 1)  is reset if   is zero, set otherwise
 * 2)  is set if a null terminating character is found in , reset otherwise
 * 3)  is set if a null terminating character is found in , reset otherwise
 * 4)  is set to
 * 5)  is reset
 * 6)  is reset

, Packed Compare Explicit Length Strings, Return Index. Compares strings of explicit length and generates index in.

 Operands 

arg1 arg2 IMM8
 * XMM Register
 * XMM Register
 * Memory
 * 8-bit Immediate value

 Implicit Operands 


 * holds the length of
 * holds the length of

 Modified flags 


 * 1)  is reset if   is zero, set otherwise
 * 2)  is set if   is < 16(for bytes) or 8(for words), reset otherwise
 * 3)  is set if   is < 16(for bytes) or 8(for words), reset otherwise
 * 4)  is set to
 * 5)  is reset
 * 6)  is reset

, Packed Compare Explicit Length Strings, Return Mask. Compares strings of explicit length and generates a mask stored in.

 Operands 

arg1 arg2 IMM8
 * XMM Register
 * XMM Register
 * Memory
 * 8-bit Immediate value

 Implicit Operands 


 * holds the length of
 * holds the length of

 Modified flags 


 * 1)  is reset if   is zero, set otherwise
 * 2)  is set if   is < 16(for bytes) or 8(for words), reset otherwise
 * 3)  is set if   is < 16(for bytes) or 8(for words), reset otherwise
 * 4)  is set to
 * 5)  is reset
 * 6)  is reset