The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ChildoftheHorn on November 17, 2006, 03:14:58 AM

Title: How do I do an identifier?
Post by: ChildoftheHorn on November 17, 2006, 03:14:58 AM
Alright, I need to convert all periods in a string to commas and visa versa.
I need to analyze it bit by bit (I have to check for zeros before either a comma or period appears for the first time),

The question is how to do this... I think I will be using ecx as the counter. How do I get string length and then how to decrement ecx by one from this initial value?
Then how do I get it to see and analyze each byte.
I was gonna use .if and .elseif and jumping to whatever....

Please Help!!!
Title: Re: How do I do an identifier?
Post by: donkey on November 17, 2006, 03:28:37 AM
REPNZ SCASB will find the 0 terminator of a Cstring

You can use SCASB to find other characters such as a period or comma as well. Mmmm, first post on the forum, a very simple task but one without any evident purpose other than to demonstrate string scanning techniques - Is this homework ???
Title: Re: How do I do an identifier?
Post by: ChildoftheHorn on November 17, 2006, 03:48:20 AM
Actually, I am making a modification to a previous homework.... which is probably why you caught that.
I just wanted to see if we could have done so differently.

In the previous work, we used a mass identifier that switched the symbols automatically.

This is my first MASM class, but by no means my first programming class...

Thanks for the info -- next task is to finish and old homework into becoming pong.
Title: Re: How do I do an identifier?
Post by: donkey on November 17, 2006, 04:16:13 AM
Well, good luck with the assignment. And don't be shy to drop by even after the class is done and you've ace'd it ;) Assembly can actually be entertaining to program in and though perhaps a little more laborious than other languages it has it's rewards. Also we have some people here who have written excellent tools to help with coding in assembly, with some of the macro libraries you'd swear it was C :)
Title: Re: How do I do an identifier?
Post by: ToutEnMasm on November 17, 2006, 06:40:16 AM


For a simple task like that ,When your datas are in memorie,you can use a loop where
ecx = the size of datas to scan and modifie
edi = the pointer on the start of buffer
al  = the value to scan

then use loop


            mov edi,~pointer~
             mov ecx,~sizeof data~
            @@:
            mov al,[edi]
            inc edi
            .if al ==~caracter to scan~
                   mov [edi],~replacement caracter (";")~               
           .endif
            dec ecx
             jnz @B


After ,you have to save the result





Title: Re: How do I do an identifier?
Post by: ic2 on November 18, 2006, 08:25:22 AM
Don't forget about
invoke SetFilePointer,hFile,0,0,FILE_END ; or FILE_BEGIN

You can even choose where you want to start reading or writing in a file by changing 0 to a number of byte to begin at...  Look it up in the Win32 Ref to get some quick facts..
Title: Re: How do I do an identifier?
Post by: donkey on November 18, 2006, 03:35:33 PM
Unfortunately the track record for homework seeekers is pretty clear, he will not be back to read these posts. Generally once the answer is given (or the request rejected) they don't return or contribute anything to the community that helped them. It's a shame, he actually gave indications that he did a bit of his own research, enough to realize that ECX was a counter when scanning strings, could have been a contributing member. I would be very surprised (and happy) to see his # of posts ever rise above 2, might help to fight this skepticism I have about first posters.

Donkey