ASM86 Assembler Summary

http://leonardo.eeug.caltech.edu/~ee5x/tools/asm86.htm

 

Description

ASM86 assembles an assembly language source file generating an output object file. Listing files and error files may also be optionally generated. ASM86 takes as input the name (including extension) of an assembly language source file and generates an output object file (default extension .OBJ), a listing file (default extension .LST), and an error file (default to the console). All three output files are optional. The object file contains the relocatable object code which is used by the linker. The listing file contains the source code along with the generated object code and diagnostic information. The error file contains all lines which generated assembly-time errors.

 

Command Line

ASM86 input_file controls

input_file
Filename of the file containing the assembly language source code to be assembled. The output files will have the same name, but with extensions .LST and .OBJ.
controls
Control the operation of the assembler (optional),

Example: ASM86 test.asm DB M1 EP

 

General Controls

Control Abbrev. Description
EJECT EJ start a new page in the output listing file (ignored if NOPAGING or NOLIST is active)
GEN GE include all source text, all macro calls, and all macro expansions in the output listing file
NOGEN NOGE include all source text and macro calls in the output listing file
GENONLY GO include all source text and macro expansions, but no macro calls in the output listing file
INCLUDE IC read input from (include) the specified file
LIST LI include subsequent lines in the output listing file
NOLIST NOLI do not include subsequent lines in the output listing file
SAVE SA save the current setting of the LIST and GEN controls
RESTORE RS restore the previous setting of the LIST and GEN controls (SAVEs and RESTOREs may be nested)
TITLE TT specifies the title to appear on subsequent page headers in the output listing file

Note: General controls may be included in the assembly language file on lines with a '$' in column 1.

 

Primary Controls

Control Abbrev. Description
DATE DA ignored
DEBUG DB include local symbol information in output object file for debugging
NODEBUG NODB do not include local symbol information in output object file
ERRORPRINT EP specifies file to send only lines with errors to, if no file is specified errors are sent to the console
NOERRORPRINT NOEP do not generate an error file or report them to the console
MACRO MR recognize and process macros in the input file
NOMACRO NOMR do not recognize or process macros in the input file (normally causes assembly errors)
MOD186 M1 recognize and use the 80186 instruction set
OBJECT OJ specify that an object module is to be created and, optionally, give the name of that file
NOOBJECT NOOJ no object module is to be created
PAGELENGTH PL specify the number of lines per page in the output listing and error files
PAGEWIDTH PW specify the number of characters per line in the output listing and error files
PAGING PI specifies the output listing file is to be formatted into pages, each with a header
NOPAGING NOPI specifies the output listing file is not formatted into pages, there is a single header at the start
PRINT PR specifies that the source listing is sent to the specified output file (or input.LST if none specified)
NOPRINT NOPR no output listing file is generated
SYMBOLS SB specifies a symbol table listing is to be included in the output listing file
NOSYMBOLS NOSB do not include the symbol table in the output listing file
TYPE TY specifies that variable and symbol type information is to be included in the output object file (used for later type checking by CREF86 and LINK86)
NOTYPE NOTY do not include type information in the output object file
WORKFILES WF specifies where the temporary files generated by the assembler are to be kept
XREF XR include a symbol cross-reference in the output listing file
NOXREF NOXR do not include the symbol cross-reference in the output listing file

Note: Primary controls may be included in the assembly language file on lines with a '$' in column 1 which appear before any other lines (blank, comment, or assembly code).

Default Controls

DATE(current date) NODEBUG NOERRORPRINT MACRO
OBJECT(input.OBJ) PAGELENGTH(60) PAGEWIDTH(120) PAGING
PRINT(input.LST) NOSYMBOLS NOTYPE LIST
WORDFILES(:WORK:, :WORK:) NOXREF GENONLY

 

ASM86 Directives (Pseudo-Ops)

Segmentation Directives

ASSUME
ASSUME segreg:name [,segreg:name]
Informs the assembler that segment register segreg will be set to point at the segment called name. If name is NOTHING, segreg is assumed to not point at any segment.
ENDS
name ENDS
Ends the segment name. Must have a matching SEGMENT directive.
GROUP name GROUP segname [,segname]
Treat all segments named by segname as a single segment called name.
Note: this does not affect the locating or combining of the segments.
SEGMENT name SEGMENT [align] [combine] ['classname']
Starts the segment name. The segment is aligned according to align (BYTE, WORD, PARA (default), PAGE, INPAGE). The segment is combined with other segments of the same name according to combine (PUBLIC, COMMON, STACK, AT addr, MEMORY). Segments of the same classname are located near each other in memory.

 

Label/Address Directives

END END [label]
Ends the current assembly file. If label is given it is used as the starting address of the program.
ENDP name ENDP
Ends the procedure name. There must be a matching PROC directive.
EQU name EQU expression
Define the symbol name to have the value of expression.
Note: this is an assembler symbol and very different from initializing a memory location.
EVEN EVEN
Force the next line (code or data) to be at an even address.
EXTRN EXTRN name:type [,name:type]
Defines name to be a global symbol of type. name must be declared PUBLIC in another file which will be linked with this file.
LABEL name LABEL type
Defines name to be a label (with the value of the current location) of the specified type. Type may be BYTE, WORD, DWORD, QWORD, TBYTE, NEAR, or FAR.
NAME NAME module_name
Assigns this file to have the name module_name in the linker.
ORG ORG addr
Force the following code to be at physical address addr.
PROC name PROC type
Starts the procedure name. type indicates how the procedure will be called, NEAR for an inter-segment CALL, FAR for an intra-segment CALL (default is NEAR).
PUBLIC PUBLIC name [,name]
Define name as a global symbol, visible to the linker. name may be referenced in other files where it is declared as EXTRN.
PURGE PURGE name [,name]
Delete name from the symbol table. It is no longer defined and cannot be used.
$ $
Value of current location counter.

 

Storage Directives

DB [label] DB initial_values
Allocates bytes of storage (one for each initial value). initial_values is a comma delimited list of constant byte expressions (8-bit values) or strings (stored one character per byte). The optional label is assigned the address of the first byte.
DW [label] DW initial_values
Allocates words of storage (one for each initial value). initial_values is a comma delimited list of constant word expressions (16-bit values) or addresses (segment name or label name). The optional label is assigned the address of the first word.
DD [label] DD initial_values
Allocates double words of storage (one for each initial value). initial_values is a comma delimited list of constant double word expressions (32-bit values), addresses (offset and segment of a label name), or floating point expressions. The optional label is assigned the address of the first double word.
DQ [label] DQ initial_values
Allocates quad words of storage (one for each initial value). initial_values is a comma delimited list of constant quad word expressions (64-bit values) or floating point expressions. The optional label is assigned the address of the first quad word.
DT [label] DT initial_values
Allocates 10 byte units of storage (10 bytes for each initial value). initial_values is a comma delimited list of constant expressions (18-digit values stored in BCD) or floating point expressions. The optional label is assigned the address of the first byte of the first value.
DUP repeat_count DUP (value)
Used in an initial value list; repeat_count copies of value are put in the initial value list.
? ?
indicates an uninitialized value in an initial value list.

 

Record and Structure Directives

RECORD name RECORD fieldname:size [,fieldname:size]
Create a record data structure (16-bits) called name with fields called fieldname, each with size bits. The fields are listed from high order bits to low order and are right justified in the word (if less than 16-bits total). Fields may be given default initial values by specifying as: fieldname:size=initial_value
STRUC name STRUC
Begin the structure definition for the structure name. The following lines should contain storage directives defining the structure elements (name, type, and default initial value).
ENDS name ENDS
End the structure definition for the structure name.

 

 

ASM86 Operators

Operators may be used on constants or addresses to form expressions which can be used in the above directives. Note: these operators are for compile-time calculations, not run-time calculations. The list is arranged in order of precedence with operators between sections being of equal precedence (and evaluated left to right).

Operator # Operands Description
()
<>
[]
.
LENGTH
SIZE
WIDTH
MASK
1
n
1
1
1
1
1
1
parenthesized expression
list of intial values for STRUC or RECORD
memory addressing
structure element or offset
number of data units allocated to a variable
number of data bytes allocated to a variable
number of bits in a RECORD or RECORD field
bit mask for a RECORD field
PTR
TYPE
THIS
SEG
OFFSET
1
1
1
1
1
syntax: type PTR, defines operand to point to type
a value indicating the type of the operand
the value of the current location
segment number of operand's address
offset within the segment of operand's address
HIGH
LOW
1
1
high byte of its operand
low byte of its operand
*
/
MOD
SHL
SHR
2
2
2
2
2
multiplication
division
remainder from division
logical shift left
logical shift right
+
-
1
1
positive sign (no effect)
negation
+
-
2
2
addition
subtraction
EQ
NE
LT
LE
GT
GE
2
2
2
2
2
2
equal (result is -1 for true, 0 for false)
not equal (result is -1 for true, 0 for false)
less than (result is -1 for true, 0 for false)
less than or equal (-1 for true, 0 for false)
greater than (result is -1 for true, 0 for false)
greater than or equal (-1 for true, 0 for false)
NOT 1 logical negation (NOT)
AND 2 logical conjuction (AND)
OR
XOR
2
2
logical inclusive injuction (inclusive-OR)
logical exclusive injuction (exclusive-OR)
SHORT 1 label in a JMP instruction is within 127 bytes

 

ASM86 Data Types

Name Value
(from TYPE)
Description
BYTE 1 a byte
WORD 2 a word (two bytes)
DWORD 4 a double word (four bytes)
QWORD 8 a quad word (eight bytes)
TBYTE 10 a ten byte (floating point or BCD) value
NEAR 255 an offset within the same segment
FAR 254 an address consisting of segment and offset

 

ASM86 Conditional Assembly Directives

%EXIT %EXIT
Exit the innermost %REPEAT or %WHILE loop.
%IF %IF (expression) THEN (code1) ELSE (code2) FI
If expression is TRUE at assembly-time then code1 is assembled into the object file, otherwise code2 is assembled. The ELSE (code2) portion is optional.
%REPEAT %REPEAT (expression) (code)
Assemble code expression times. expression is evaluated at assembly-time.
%WHILE %WHILE (expression) (code)
Repeatedly assemble code as long as expression is TRUE at assembly-time. Note: something in code should change expression to FALSE, or infinite length code results.

 

ASM86 Macro Directives

%*DEFINE %*DEFINE(macro_name) (macro definition)
Defines macro_name to expand as macro definition at assembly-time when invoked with %macro_name.
%*DEFINE %*DEFINE(macro_name(parameters)) (definition)
Defines macro_name to expand as definition, using the actual values for the symbols parameters in definition, at assembly-time when invoked with
%macro_name(actual values).
The parameters and actual values are comma delimited.
%*DEFINE %*DEFINE(macro_name) LOCAL labels (definition)
Defines macro_name to expand as definition at assembly-time when invoked with %macro_name. Any label in the definition which is in the comma delimited list labels will expand uniquely in each macro expansion if preceeded by a % (i.e. %label) in definition. The macro may also have parameters.
%' %'comment'
Comment in macro definition (does not appear in expansion).
%n %ntext
Take the next n (1-9) characters of text literally (i.e. do no translation). Useful for including characters like ',' or '%' in code.
%() %(text)
Inhibit all macro expansion of text.
%METACHAR %METACHAR(char)
Redefine the metacharacter (normally '%') to be char.
%SET %SET(symbol, expression)
Assign the value of expression to symbol. Used at macro expansion time only (not at assembly-time).

 

Macro Operators

%EQS %EQS(string1, string2)
Return TRUE if string1 equals string2 at macro expansion time.
%EVAL %EVAL(expression)
Evaluate expression at macro expansion time.
%GES %GES(string1, string2)
Return TRUE if string1 is greater than or equal to string2 at macro expansion time.
%GTS %GTS(string1, string2)
Return TRUE if string1 is greater than string2 at macro expansion time.
%LES %LES(string1, string2)
Return TRUE if string1 is less than or equal to string2 at macro expansion time.
%LTS %LTS(string1, string2)
Return TRUE if string1 is less than string2 at macro expansion time.
%NES %NES(string1, string2)
Return TRUE if string1 and string2 are not equal at macro expansion time.

 

Built-In Macro Functions

%CI %CI
Gets a character of input from the user at assembly-time and returns the character (no prompting).
%CO %CO(char)
Output character char to the user at assembly-time.
%IN %IN
Prompts the user for input ('>>' prompt) at assembly-time and returns the line of input.
%LEN %LEN(text)
Has the value of the number of characters in text.
%MATCH %MATCH(ident1 delim ident2) (text)
The string text is searched for the first occurrence of character delim. If delim is found all characters to the left of it are assigned to ident1 and all characters to the right are assigned to ident2. If delim is not found all of text is assigned to ident1 and ident2 is a null string.
%OUT %OUT(text)
Output text to the user at assembly time.
%SUBSTR %SUBSTR(text, expression1, expression2)
Generates a string consisting of a substring of text starting at character position expression1 and continuing for expression2 characters.

 


Last updated September 24, 2002 09:30 PM by glen@caltech.edu

copyright © 1997, Glen George. All rights reserved. Reproduction of all or part of this work is permitted for educational or research use only, provided that this copyright notice is included in any copy.