Connecting Tech Pros Worldwide Forums | Help | Site Map

FASM String concatenation

Member
 
Join Date: Jan 2008
Posts: 116
#1: Feb 5 '09
I am trying to learn assembly. I am able to get a pointer to a string and i want to concatenat that string to another hard coded string. How could one do this?
RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,392
#2: Feb 5 '09

re: FASM String concatenation


Here are the steps necessary:
  1. Compute the sum of the string's lengths.
  2. Save the original string length.
  3. Fix the string length at 255.
  4. Save the new string length.
  5. Copy source1 string to your destination string.
  6. Get the length of the second string.
  7. Compute the length and truncate if necessary.
  8. Skip to the end of the first string in your destination string.
  9. Perform the concatenation by placing the second string at the position of the first string.
  10. Clean up.

You can look here for more details (http://maven.smith.edu/~thiebaut/Art.../artofasm.html)
Member
 
Join Date: Jan 2008
Posts: 116
#3: Feb 6 '09

re: FASM String concatenation


Thanks for the great link RedSon. I found a shortcut answer for me here:http://fasmlib.x86asm.net/ It has a function "str.cat" which is exactly what i was looking for. The source code is available so I'm gonna read through it in hopes of better understanding (along with this online book youve pointed me to)
Reply