The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
October 23, 2018, 02:30:24 PM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  Project Support Forums
| |-+  The GeneSys Development System
| | |-+  User Contributed Code (Moderators: Vortex, PBrennick)
| | | |-+  Function with variable number of parameters
« previous next »
Pages: [1] Print
Author Topic: Function with variable number of parameters  (Read 7669 times)
Vortex
Raider of the lost code
Moderator
Member
*****
Gender: Male
Posts: 3460



Function with variable number of parameters
« 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.

Code:
.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 :

Code:
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]
Logged

Vortex
Raider of the lost code
Moderator
Member
*****
Gender: Male
Posts: 3460



Re: Function with variable number of parameters
« Reply #1 on: November 06, 2011, 10:32:48 AM »

Here is another optimized version of the wsprintf simulator.

* wsp16.zip (1.86 KB - downloaded 422 times.)
Logged

PBrennick
Never be satisfied
Moderator
Member
*****
Gender: Male
Posts: 2096


Never under-estimate the power of an idea


Re: Function with variable number of parameters
« Reply #2 on: November 20, 2011, 01:21:26 AM »

Thank you my friend. We must talk about the project.

Paul
Logged

The GeneSys Project is available from:
The Repository or My crappy website
Vortex
Raider of the lost code
Moderator
Member
*****
Gender: Male
Posts: 3460



Re: Function with variable number of parameters
« Reply #3 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
Logged

Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!