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
Posted on 2001-05-30 10:22:00 by e-nigma
Remember, a string is in fact a series (or string :D ) of bytes. So all you have to do is something like this:

MyString db "Hello",0
MyBuffer db 20 dup (?)

  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
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
Posted on 2001-05-30 12:34:00 by Mirno
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.
Posted on 2001-05-30 14:42:00 by Nokturnal
Thanks. Now I'll try to code it.
Posted on 2001-05-30 21:56:00 by e-nigma