quick navigator
Products
Technologies
Development Tools
Documentation
ApBuilder
Application Notes
Backgrounder
Datasheets
Development Tools
Manuals
Packaging Data
Papers
Specification Updates
Technical Notes
Support
Price Quote and Ordering
Product Selector
Software Support
Related Sites
MCS96/296 Microcontrollers
Flash Memory Components
SmartDie® Products
Developer Home Contents Search Contact Us Support Intel(r)
 

Specifying ASM-51 Options From the Command Line


Often in developing programs for embedded products, it is advantageous to use the same assembly source file(s) for a number of different products, selecting different options through conditional assembly switches. The straightforward way to do this is to assemble the code with the switches set for one model, then edit the source file to change the switches, then re-assemble. This has a number of drawbacks, including the necessity of editing the source file, and having temporary files laying around, to cause confusion and clutter. A much better method is to keep only one source file, and specify different options from the DOS command line when it is assembled. Fortunately, ASM51, as well as most other Intel assemblers, provides a method to do this.

ASM51 provides a macro command, "%IN" which will pause the assembly operation and wait for a line to be input from the console. This input can be a line of text or a numerical value. Consult the manual for further details. Also provided is "%OUT", which will print text to the console to prompt the operator. The trick is to force ASM51 to take its input from a file, instead of directly from the console. This can be done with DOS's input redirection facility.

For instance, a file, let's call it "QUERY.ASM", such as the following, will ask for a password, then continue depending on the value of that password:

	; test of macro processor's IN and OUT commands

false equ 0
true equ not false
%out(enter password )

%if(%eqs(%IN,swordfish
))then(
result set true
%out(At your command
)
)else(
result set false
%out(Get Lost !!!
)
)fi
end

Note the following items:

    1) %eqs is case sensitive. "swordfish" does not equal "SWORDFISH".
    2) The word being tested for is followed immediately by a <CR>, and the first character of the next line is the ending ")", i.e., the test is being performed against "swordfish<CR>". Don't indent the closing parenthesis!

When this file is assembled, it will ask for the password, then alter its operation accordingly.

Manually entering options works fine if there is just one or two, but it is more accurate and less tedious to put all the options in a file, such as a "batch" or "make" file. This can be done in a number of ways. For instance, create a file called PASSWORD containing the one line:

	swordfish

Then type at the DOS command line:

	ASM51 QUERY.ASM<PASSWORD

ASM51 will then assemble QUERY.ASM, taking its password from the PASSWORD file. If there is more than one %IN, each response should occur on a separate line.

The above line can also be placed within a batch file, but is should be noted that if the command ASM51 is itself a batch file which invokes the real assembler, then the redirected input will not be passed on to the programs within the batch file.

Another technique is to make a file, let's call it "SCRIPT.SCR", such as:

	ASM51 QUERY.ASM
swordfish
exit

Don't forget the exit on the last line, or the <CR> after it, or the secondary command processor will never terminate.

Then invoke the assembler via a secondary command processor, thusly:

	COMMAND<SCRIPT.SCR

This method has the advantage that the assembler invocation line and all input to the assembler is contained in one file, instead of two or more, so it is easier to maintain. Also, the assembler can be run multiple times, with different options, from the same script.



To top of page


* Legal Information © 1999 Intel Corporation