Hi! I'm trying to learn simple ASM calculation and string modification. I've decided to starting with simple algorithm. Such as printing a string from last character. Example: "ASM is great" will be "taerg si MSA" Here is goes: I've coded a simple app which has two edit box, a "Generate" button and an "Exit" button. Algo: 1)Get the user input in EditBox #1 2)Take the first character 3)Save it 4)Get next character 5)Print it in EditBox #2 Please don't write the solution. First I'll try to do it myself and if I couldn't then I'll ask for it. In the mean time, please tell me how to save each character show that I can print it oppositely? Thanks
Remember, a string is in fact a series (or string :D ) of bytes. So all you have to do is something like this:
This is a (very) simple move, and you'll want a loop of some sort. I would advise you to use StrLen from the masm32 lib. Also remember to terminate your copied string! Also look at "Turning a string backwards???", but only after you've done your own work :D Mirno
.data MyString db "Hello",0 MyBuffer db 20 dup (?) .code lea esi, MyString ; esi holds the source string address lea edi, MyBuffer ; edi holds the destination string address mov al, ; Copy the first character from esi mov , al ; Place it in the first byte of our buffer
There is a API in the Masm32.inc / Masm32.lib that will reverse a string for you. revstr. revstr revstr proc lpszSource:DWORD,lpszDest:DWORD Description: revstr reverses a zero terminated string in lpszSource and places it in lpszDest. Parameters: 1. lpszSource The address of the source string. 2. lpszDest The address of the destination buffer. Return Value There is no return value. Comments The destination buffer must be at least the size of the source buffer otherwise a read page fault will occur.
Thanks. Now I'll try to code it.