News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CopyCat

Started by PBrennick, February 07, 2009, 05:06:37 PM

Previous topic - Next topic

PBrennick

While working on Sudoku, I was driven nuts (until I discovered the culprit) by the fact that lstrcpy, lstrcat and lstrlen do not preserve certain registers. Suduko uses lstrcpy 29 times, lstrcat 108 times and lstrlen 6 times. Needless to say, it p***** me off.

I have been aware of the CopyCat macro (Mark Jones?) and really liked the idea of bundling the two operations so I decided to go a few steps further.

My CopyCat algo has four modes of operation as shown below. The length of the result iis always returned in EAX no matter what mode you choose to use so lstrlen is taken care of inherently even though there is a specific option for it.

USAGE: The four modes are determined by the values passed in the last two pointers.
     1. If Source1 is NULL, Source2 is concatenated to Dest.
     2. If Source2 is NULL, Source1 is copied to Dest.
     3. If both are NULL, the length of Dest is returned.
     4. If neither are NULL, Source1 is copied to Dest and then Source2 is concatenated to it.

The algoryth is contained in the text file (in the bundle). Also included is a GUI test piece to show the algorythm in action. It is a little bit of an overkill just to prove the functionality but it helped me re-structure my brain while I was in the hospital. The Game, the Installer and this algo were ALL developed during my rehab.

CopyCat, if Vortex approves, will be added to the GeneSys SDK, but, it is free for all no matter how you build your gems.

Paul


[attachment deleted by admin]
The GeneSys Project is available from:
The Repository or My crappy website

Vortex

Nice addition Paul. Useful algo when you deal with a lot of strings.

PBrennick

Yeah, I like it, also. Mark comes up with these truly good ideas. I hope he does not mind that I reworked it to include more options.

Paul
The GeneSys Project is available from:
The Repository or My crappy website