Let's say we have a given string of chars
DataString DB 'AGIJKSZ', 0FFH ;
What would be the most time-effective procedure to find let's say J
in it?
By time-effective I mean least amount of clock ticks.
It's a x86 processor with these instruction sets:
MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, EM64T, VT-x, AES, AVX, AVX2, FMA3, TSX
Let's assume that both string and searched character can be changed but only via editing the code, and we're always looking for a single character. The string is ASCII. End of string is marked by FF
Answer should be just setting EAX
to found 1
/ not found 0
.
This is what I can think of
FindChar_1 PROC
MOV ESI, OFFSET DataString ;
SI
MOV AH, 'J' ;
Check_End:
CMP BYTE PTR [ESI], 0FFH ;
JE Not_Find ;
CMP AH, [ESI] ;
'DataString'
JE Got_Equal ;
ADD ESI, 1 ;
JMP Check_End ;
Got_Equal:
MOV DL, [ESI] ;
JMP Done
Not_Find:
MOV EAX,0 ;
RET ;
Done:
MOV EAX,1 ;
RET ;
FindChar_1 ENDP
EDIT:
Now I realize that there I something else I should have mentioned. I'm using masm32 so instructions I can use are limited to the very basic ones.