News:

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

Main Menu

ASM4FUN is almost ready

Started by frktons, November 08, 2021, 11:10:02 PM

Previous topic - Next topic

frktons

Hello beautiful ASM people.  :eusa_dance:

Today I downloaded the MASM32 package for win10, the old one is missed with old disk
and not anymore functioning probably.

The installation process was ok, the help file WIN32.HLP put online for MASM Editor.

So let's start with the first  episode of the ASM FUN SAGA.

As I mentioned elsewhere, I want to find a fast way to:

1) convert 1 million strings into INTEGER numbers
2) compare the first one of them with the following until I find a gap of 10 units or more (bigger number)
or less (smaller number).

3) display the number of occurrences of the bigger, and smaller numbers found, so that when one is found
the process restart from that point forward in the list (an array probably).

Let's start with the first part "Conversion of 1 million strings into INTEGER numbers.

Any suggestion is welcome

:thumbsup:
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

hutch--

What format are the string in ?

jj2007

Quote from: frktons on November 08, 2021, 11:10:02 PMI want to find a fast way to:

1) convert 1 million strings into INTEGER numbers
2) compare the first one of them with the following until I find a gap of 10 units or more (bigger number)
or less (smaller number).

Roughly half a second for a Million numbers, with a non-specialised algo. What do you mean with "fast", and why does it have to be fast?

frktons

Quote from: hutch-- on November 09, 2021, 12:05:26 AM
What format are the string in ?

Hi Steve,

just four ASCII bytes: "1234" to convert into an integer.

Quote from: jj2007 on November 09, 2021, 01:21:18 AM
Quote from: frktons on November 08, 2021, 11:10:02 PMI want to find a fast way to:

1) convert 1 million strings into INTEGER numbers
2) compare the first one of them with the following until I find a gap of 10 units or more (bigger number)
or less (smaller number).

Roughly half a second for a Million numbers, with a non-specialised algo. What do you mean with "fast", and why does it have to be fast?

Hi JJ.

I have to perform the comparison many times, even if the conversion could be done just once
and store the INTEGER numbers into an array.

Thanks guys. always kind and helpful.

In pseudocode it could be expressed like:

START TIME
DO UNITIL 1M times
   
    number = convert(string)

END DO
END TIME

PRINT "Time count is "; TIME_USED





There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

nidud

#4
deleted

frktons

Quote from: nidud on November 09, 2021, 04:35:38 AM
    mov     ecx,[rcx]
    and     ecx,not '0000'
    movzx   eax,cl
    movzx   edx,ch
    imul    eax,eax,1000
    imul    edx,edx,100
    add     eax,edx
    shr     ecx,16
    movzx   edx,cl
    shr     ecx,8
    imul    edx,edx,10   
    add     eax,edx
    add     eax,ecx


Thanks my friend, I am going to study the code to understand what exactly you do
with this serie of multiplications and additions, shift right and moving around registers, I have some intuition though.

:-)

There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

hutch--

Hi Frank,

It sounds like you are doing some form of integer sort algorithm. 4 digits numbers in the range of 0000 to 9999 should in fact be very simple and really fast if you do it right. Something like a "letterbox" sort which is basically an array of 9999 members which you just write each number to its array index then scan from one end of the array to the other optionally dropping any blanks.

frktons

Hi Steve.

My goal is not to sort the array of strings, but to convert a fixed length string of 4 bytes
into an Integer (4 bytes as well).

I have about 8 millions strings of 4 bytes with values between "0000" to "9999" but the two extreme are not there.

I think storing the 8 millions strings into an array, convert them into 8 millions INTEGER of 4 bytes
is taking quite a while.

I am going to test it in PowerBasic, that I somehow remember how to code and find the needed info.
After I will do a loop in ASM 1 to 8 millions times and find a better solution in speed and, why not, elegance.

When finished I will post the results, and try to make it FUN and useful. Then the optimization will start.

:thumbsup:
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama