flat assembler
Message board for the users of flat assembler.

Index > DOS > Concat Strings

Author
Thread Post new topic Reply to topic
Jakevfr



Joined: 03 Feb 2007
Posts: 26
Jakevfr
How can I concat (add) two strings together in DOS? I'm wanting to have the user input their first name, then their last name, and then add them together for their full name.

Thanks
Post 15 May 2007, 20:32
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Supposing NULL terminated strings and flat mode to simplify things:
Code:
strCat: ; SI = destination; DI = source; DF = 0
  lodsb
  test al, al
  jnz strCat

  xchg si, di
  dec di

.copyChar:
  lodsb
  stosb
  test al, al
  jnz .copyChar

  ret
    
Post 15 May 2007, 21:24
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
don't forget to add space between them Wink
Post 16 May 2007, 00:08
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Code:
mov byte[buffer], 0

irp source, szFirstName, szSpace, szLastName
{
  mov si, buffer
  mov di, source
  call strCat
}    
Wink
Post 16 May 2007, 01:01
View user's profile Send private message Reply with quote
Jakevfr



Joined: 03 Feb 2007
Posts: 26
Jakevfr
Thanks!
Post 16 May 2007, 20:37
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.