The MASM Forum Archive 2004 to 2012

Project Support Forums => The GeneSys Development System => User Contributed Code => Topic started by: Vortex on December 08, 2008, 10:33:42 AM

Title: Function with variable number of parameters
Post by: Vortex on December 08, 2008, 10:33:42 AM
Here is a function to simulate partially wsprintf. The purpose is to concatenate multiple strings into a single string copied to a destination buffer. The only accepted format specification is the symbol %. This is enough to concatenate strings.


.386
.model flat,stdcall
option casemap:none

include    \GeneSys\include\windows.inc
include    \GeneSys\include\kernel32.inc
include    \GeneSys\include\GeneSys.inc

includelib \GeneSys\lib\kernel32.lib
includelib \GeneSys\lib\user32.lib
includelib \GeneSys\lib\GeneSys.lib

wsp PROTO C buffer:DWORD,format:DWORD,args:VARARG

.data

format1 db 'This is a % % to % %',0
str1    db 'wsp',0
str2    db 'demo',0
str3    db 'concatenate',0
str4    db 'strings.',0

.data?

buffer  db 100 dup(?)

.code

start:

    invoke   wsp,ADDR buffer,ADDR format1,\
             ADDR str1,ADDR str2,ADDR str3,ADDR str4
    invoke   ConsoleOut,ADDR buffer
    invoke   ExitProcess,0

END start


Result :

This is a wsp demo to concatenate strings.

The wsp function retuns the size of the final string copied to the buffer.

[attachment deleted by admin]
Title: Re: Function with variable number of parameters
Post by: Vortex on November 06, 2011, 10:32:48 AM
Here is another optimized version of the wsprintf simulator.
Title: Re: Function with variable number of parameters
Post by: PBrennick on November 20, 2011, 01:21:26 AM
Thank you my friend. We must talk about the project.

Paul
Title: Re: Function with variable number of parameters
Post by: Vortex on November 27, 2011, 08:32:00 AM
Hi Paul,

I sent you three personal messages. Did you receive them my friend?

If you cannot access me via PM, here is my email address : vortex_1 at hotmail dot com