The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Farabi on May 01, 2005, 04:48:09 AM

Title: String dificulties
Post by: Farabi on May 01, 2005, 04:48:09 AM
It is not easy handling a string on assembler. Does anyone know what function I shall use to unied a string?

example:
t db "d:\",0
t2 db "my.exe",0

How to make it become one string?
Title: Re: String dificulties
Post by: MichaelW on May 01, 2005, 06:00:54 AM
In the MASM32 library there is szappend, szCatStr, szMultiCat, ucCatStr, and ucMultiCat. As far as I know, for all of these procedures, the programmer is responsible for ensuring that the destination buffer is large enough to contain the concatenated strings.
Title: Re: String dificulties
Post by: AeroASM on May 01, 2005, 11:33:20 AM
You could also use lstrcat, but this is slow.
Title: Re: String dificulties
Post by: Vortex on May 01, 2005, 01:13:55 PM
Hi Farabi,

Here is an example using szCatStr

.386
.model flat,stdcall
option casemap:none

include         \masm32\include\windows.inc
include         \masm32\include\kernel32.inc
include         \masm32\include\masm32.inc
includelib      \masm32\lib\kernel32.lib
includelib      \masm32\lib\masm32.lib

.data

t   db "d:\",0
    db 6 dup(0) ; 6 bytes for the string concatenation
t2  db "my.exe",0


.code

start:

    invoke  szCatStr,ADDR t,ADDR t2
    invoke  StdOut,ADDR t
    invoke  ExitProcess,0

END start