News:

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

How do I do an identifier?

Started by ChildoftheHorn, November 17, 2006, 03:14:58 AM

Previous topic - Next topic

ChildoftheHorn

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!!!

donkey

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 ???
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ChildoftheHorn

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.

donkey

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 :)
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ToutEnMasm



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






ic2

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..

donkey

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
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable