News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

parameters

Started by x-logan, November 06, 2005, 12:38:02 PM

Previous topic - Next topic

x-logan

hi
how do you can make some program that you can use a parameters list que you compiled it and use it in the dos prompt
like

c:>\program param1 param2

hope you can help me
thanks

MichaelW

I'm assuming you are asking about using command-line arguments. For a Windows app you could use the GetCommandLine function to retrieve the command-line string and then you could process the string to extract the individual arguments. The MASM32 library includes three command line functions. The most recent, I think, is GetCL.

For a DOS program the command-line string is in the Program Segment Prefix (PSP) starting at offset 80h. The PSP is a 256-byte block of memory that immediately precedes the program in memory. For a COM program the PSP is in the same memory block as the program, and the loader sets all of the segment registers to the segment address of the PSP. For an EXE program the PSP memory block is separate from the program memory block(s). The loader sets DS and ES to the segment address of the PSP, but the normal startup code (for example, the code added by the .STARTUP directive for MASM) will change the value in DS. From memory, the first byte of the command line contains the number of characters in the command line not including the trailing CR (ASCII character 13), and the command line proper starts at offset 81h. Most programmers ignore the first byte and find the end of the command line by scanning for the trailing CR. Command line arguments are normally separated by spaces or tabs.

eschew obfuscation

dsouza123

The msort.asm example program that comes with MASM32 uses the commandline parameters.