News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Recent posts

#1
The Campus / Re: Simple array in assembly l...
Last post by daydreamer - Today at 05:04:31 PM
@nocforme
Old trick for using 256*256 2d array is use BL for x and BH for y
@lord adef
Depending on CPU,that advice was for P4
If I have slow loop,for example loop that contains api calls that take milliseconds
It doesn't matter,might be more convenient with
Dec variable
Than register preservation push/pop + Dec reg or sub reg,1
#2
The Orphanage / Re: HOT !!??
Last post by daydreamer - Today at 04:40:29 PM
Quote from: zedd151 on Today at 07:11:04 AMFor a bit of levity here, in the days of old... in any country (or empire) the standard foot was defined as the size of the emporers (or king, etc) actual foot length. Leading to incompatibility issues between nations.
There is small emperors ,Napoleon was short,while a Danish king around 1900 was over 2 metres tall
No wonder standard foot from other nations could be different, no wonder French converted to Meter system :)

Reminds me of old sigline from other forum
There are 10 types of people ,those who understand binary and ... :D

In the medevial world ,sons trained in fathers shop,where they made handmade wares,not only shoes
Isn't it more probably ,sons inherited similar foot size as father ?
#3
The Laboratory / Re: SIMD_BinaryScan (Instring ...
Last post by guga - Today at 03:22:03 PM
HI guys, i updated the 1st post and included the translation to masm of the last working version. I attached the file that i had to disassemble (as did before in other threads) which is more guaranteed to work (Just rename the xmmword to oword if needed). Additionally, i added on the post itself my attempt to port it to masm compatible syntax as well masm macros (But, i dont know if i translated correctly)

Btw, due to the limitations of characters lenght on the forum, i had to remove all the comments on the 1st post., but if needed here are the comments of the functions themselves

;;
    SIMD_BinaryScan
        This function performs a binary search for a chunk of data (pSearchPattern) within a larger dataset (pDataBuffer).
        It uses SSE2 instructions for optimization and speed, especially with large datasets.
        The function can be used to find data of any size, including strings (case-sensitive) within a larger text.

    Parameters:
        pDataBuffer (in):       Pointer to the start of the larger dataset in which the search is performed.
                                This is the buffer in which you are searching.
        DataSize (in):          The size (in bytes) of the dataset. The size must be greater than or equal to 16 bytes.
        pSearchPattern (in):    Pointer to the start of the search pattern (the data chunk to search for within the dataset).
                                This is the smaller data chunk you are searching for.
        PatternSize (in):       The size (in bytes) of the search pattern.

    Return Value:
        Success: If the pattern is found, the function returns a pointer to the starting position of the matching chunk in the dataset.
        Failure: Returns 0 (&NULL) if the pattern is not found in the dataset.
;;

;;
    CompareSmallDataBlock
        This function performs a byte-by-byte comparison of a small dataset (<= 16 bytes) with a search pattern.
        It is used as a fallback when the dataset is too small for SIMD optimizations.

    Parameters:
        pDataBuffer (in):       Pointer to the start of the dataset.
        DataSize (in):          The size (in bytes) of the dataset.
        pSearchPattern (in):    Pointer to the start of the search pattern.
        PatternSize (in):       The size (in bytes) of the search pattern.

    Return Value:
        Success: If the pattern is found, the function returns a pointer to the starting position of the match.
        Failure: Returns 0 (&NULL) if the pattern is not found.
;;

;;
    VerifyPatternMatch
        This function performs a detailed comparison of a search pattern with a dataset block.
        It is used after a potential match is found in the main function to confirm the match.

    Parameters:
        pDataBuffer (in):       Pointer to the start of the dataset block.
        pSearchPattern (in):    Pointer to the start of the search pattern.
        PatternSize (in):       The size (in bytes) of the search pattern.

    Return Value:
        Success: If the pattern matches, the function returns a pointer to the starting position of the match.
        Failure: Returns 0 (&NULL) if the pattern does not match.
;;


And below is a example (I hope) how to call this function:

; Define data and code sections
.data
    ; Define example data
    haystack db "This is a simple string to search within. While trying to find sinp from sinples string", 0
    needle db "search wi", 0

    ; Variables to store string lengths
    haystack_len dd ?
    needle_len dd ?

    ; Variable to store the search result
    result dd ?

.code
start:
    ; Calculate the length of the haystack string
    invoke lstrlen, addr haystack
    mov haystack_len, eax

    ; Calculate the length of the needle string
    invoke lstrlen, addr needle
    mov needle_len, eax

    ; Call the SIMD_BinaryScan function
    invoke SIMD_BinaryScan, addr haystack, haystack_len, addr needle, needle_len
    mov result, eax

    ; Check the result
    .if result == 0
        ; If the result is 0, the pattern was not found.
        print "Pattern not found.", 13, 10
    .else
        ; If the result is non-zero, the pattern was found.
        print "Pattern found at position: "
        print str$(result), 13, 10
    .endif

    ; Terminate the program
    invoke ExitProcess, 0
#4
The Laboratory / Re: SIMD_BinaryScan (Instring ...
Last post by zedd151 - Today at 11:39:07 AM
I came back inside early. I didn't want to make you wait too long...  :smiley:

Okay. Indeed I did make an error when saying that "there was an error in the position where the string is found".
My mistake. The couple errors that I thought I found were the second or more occurrence of the string, not the first. The position listed is for the first occurrence, even if multiple occurrences are there.

I tested the first 40 Examples out of the 167 Examples tested. Almost 25%

The results of 38 of those are all correct as well as the positions of where that first occurence of each string is found, the 2 Examples where the string is not found the 'not found' result is also correct (Example 19 and Example 25).

I didn't go any further as I think I will not find any errors. It does indeed appear that there are no errors in the results.   :thumbsup:
#5
The Orphanage / Re: Seemingly pointless rambli...
Last post by stoo23 - Today at 11:20:48 AM
My God,.. the Hide of this individual is truly extraordinary ....  :dazzled:  :rofl:

We all get old and so will you .... buddy

I have led an extraordinarily enjoyable, rich and diverse life , engaged in some fantastic and at times real altruistic and meaningful work, without ever having to deal with anyone as annoyingly rude and cock-sure as yourself until now, .... thankfully.
So 'Feck-Off' and go bother some cats somewhere, you Gobshite.
#6
The Laboratory / Re: SIMD_BinaryScan (Instring ...
Last post by zedd151 - Today at 11:12:34 AM
Okay, I will reexamine the results. I could have made a mistake too, when I looked the first time.

I am going to be away from computer for some time. It's beautiful outside, I keep going back in to the computer, and back outside...

Give me about an hour to finish checking each result properly.  :smiley:
So I can enjoy the weather a little longer.   :azn:
#7
The Laboratory / Re: SIMD_BinaryScan (Instring ...
Last post by guga - Today at 11:08:27 AM
Tks, Btw...about the position...its´rather an index than the position. For example, on the 1st case

TestingString: 578987hGugf8ahj1g1ghdlgjGughjkhjk8ahj18ahj1g1ghdmerdalgjg1ghdlgj8a8ahj1g1ghdlgjhj1g1ghdlgj
TestingString Size: 90
CharToFind: merdalgjg1ghdlgj8a8ahj1g1
CharToFind Size: 25
Found at: Pos (48) - merdalgjg1ghdlgj8a8ahj1g1ghdlgjhj1g1ghdlgj

The value of 48 means we have 48 bytes before the match. Therefore the pattern was located at the 49th byte. If needed i´ll redo the printing to reflect the exact position where the pattern was found.

"578987hGugf8ahj1g1ghdlgjGughjkhjk8ahj18ahj1g1ghd" = 48 bytes (Pos)

found it at the 49th byte: merdalgjg1ghdlgj8a8ahj1g1ghdlgjhj1g1ghdlgj


When i did the printf i simply calculated the returned address in eax and subtracted from the beginning of the data.

esi = Initial TestingString address

eax = Pattern address found

Pos = eax - esi
#8
The Orphanage / Re: Seemingly pointless rambli...
Last post by ognil - Today at 11:04:42 AM
Please Relax: As a pensioner you are OK for Administrator.

I can't and don't want to be an administrator because I am a supporter of a free and uncensored internet and I have an interesting job.

Please, just try not to mess with me because I would rather spend some time in peace to finish my current project than go into explanation mode with you.
#9
The Laboratory / Re: SIMD_BinaryScan (Instring ...
Last post by zedd151 - Today at 10:59:23 AM
I think I found a couple errors in the position where string was found.
I'll make a report for each case where an error found....

It'll take some time.
#10
The Laboratory / Re: SIMD_BinaryScan (Instring ...
Last post by zedd151 - Today at 10:55:05 AM
Quote from: guga on Today at 10:50:09 AMtks, but the result is empty. I guess you forgot to paste the result on the text file.
And I forgot to test the zip file. That was indeed my fault, sorry.

I have corrected that and reattached it above, where it was originally.

No, I have not inspected that the results were accurate that will take a little time... I'll have to get back to you in a little while.