News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Very fast character counter

Started by hutch--, February 24, 2022, 05:58:57 AM

Previous topic - Next topic

hutch--

This SLL module is a character counter that is simple enough to use basic code that has many uses. The original was designed to do things like matching CR and LF characters where the text you may be evaluating may have been sources from Unix and MAC sources with non CRLF line terminations.

It only took a minor mod for it to be useful in binary mode as well as text mode and you certainly will not grow old waiting for it to munch through very big files. On most files, you cannot get a timing as it is too fast and you get 0 as the duration. I have tested it with a 1.6 gig binary file and on my old i7, about 2.6 seconds.

It is easy enough to use, create an empty DWORD array then pass the file source basic string and the empty array to the SLL and the algorithm redimensions and fills the 256 character with the count of each character.

  ' ********************
    bincnt text$,dwArr()        ' <= character count SLL code here
  ' ********************

To get the count of any character, just load the array member based off the character you want.

dwArr(65) will give you the count for the "A" character as a DWORD variable.