flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Roman 10 Jul 2013, 17:44
I do not understand how they work EDX and EAX registers in pcmpistri .
Maybe someone can describe steps the procedure ptsmpistri , using simple commands? |
|||
![]() |
|
Madis731 10 Jul 2013, 18:19
Check out this link:
http://www.strchr.com/strcmp_and_strlen_using_sse_4.2 This section describes what you want: Equal ordered (imm[3:2] = 11). Substring search (strstr). The first operand contains a string to search for, the second is a string to search in. The bit mask includes 1 if the substring is found at the corresponding position: operand2 = "WhenWeWillBeWed!", operand1 = "We" IntRes1 = 000010000000100 There's also code posted to do just that: Code: ; compile with FASM ; Immediate byte constants EQUAL_ANY = 0000b RANGES = 0100b EQUAL_EACH = 1000b EQUAL_ORDERED = 1100b NEGATIVE_POLARITY = 010000b BYTE_MASK = 1000000b ; ==== strstr ==== strstr_sse42: ; ecx = haystack, edx = needle push esi push edi MovDqU xmm2, dqword[edx] ; load the first 16 bytes of neddle Pxor xmm3, xmm3 lea eax, [ecx - 16] ; find the first possible match of 16-byte fragment in haystack STRSTR_MAIN_LOOP: add eax, 16 PcmpIstrI xmm2, dqword[eax], EQUAL_ORDERED ja STRSTR_MAIN_LOOP jnc STRSTR_NOT_FOUND add eax, ecx ; save the possible match start mov edi, edx mov esi, eax sub edi, esi sub esi, 16 ; compare the strings @@: add esi, 16 MovDqU xmm1, dqword[esi + edi] ; mask out invalid bytes in the haystack PcmpIstrM xmm3, xmm1, EQUAL_EACH + NEGATIVE_POLARITY + BYTE_MASK MovDqU xmm4, dqword[esi] PAnd xmm4, xmm0 PcmpIstrI xmm1, xmm4, EQUAL_EACH + NEGATIVE_POLARITY ja @B jnc STRSTR_FOUND ; continue searching from the next byte sub eax, 15 jmp STRSTR_MAIN_LOOP STRSTR_NOT_FOUND: xor eax, eax STRSTR_FOUND: pop edi pop esi ret |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.