





					  Elements of the Assembler



		 2.1  Introduction

		 All assembly language programs	consist	of  one	 or
		 more  statements  and	comments.   A  statement or
		 comment is a combination of  characters,  numbers,
		 and   names.	 Names	and  numbers  are  used	 to
		 identify   values   in	  instruction	statements.
		 Characters  are used to form the names	or numbers,
		 or to form character constants.

		 The following sections	 describe  what	 characters
		 can  be used in a program and how to form numbers,
		 names,	statements, and	comments.


		 2.2  Character	Set

		 MASM recognizes the following character set:

		      A	B C D E	F G H I	J K L M	N O P Q	R S T U	V W X Y	Z
		      a	b c d e	f g h i	j k l m	n o p q	r s t u	v w x y	z
		      0	1 2 3 4	5 6 7 8	9
		      ?	 @  _  $ : . [ ] ( ) < > { }
		      +	- / * &	% ! ' ~	| \ = #	^ ; , `	"


		 2.3  Integers

		 Syntax

		      digits	  digitsB      digitsQ	    digitsO
		      digitsD	   digitsH

		 An integer represents an integer number.  It is  a
		 combination   of   binary,   octal,   decimal,	 or
		 hexadecimal digits and	 an  optional  radix.	The
		 digits	 are a combination of one or more digits of
		 the specified radix: B, Q, O,	D,  or	H.   If	 no
		 radix	is  given,  MASM  uses	the current default
		 radix (typically decimal).   The  following  table



								2-1


















	      XENIX Macro Assembler Reference Manual



	      lists the	digits that can	be used	with each radix.
	      (Radix can be either upper or lowercase.)
	      _______________________________________________________
	      |Radix   Type	     Digits			     |
	      |______________________________________________________|
	      |______________________________________________________|
	      |	 Q     Octal	     0 1 2 3 4 5 6 7		     |
	      |	 O						     |
	      |______________________________________________________|
	      |______________________________________________________|
	      |	 H     Hexadecimal   0 1 2 3 4 5 6 7 8 9 A B C D E F |
	      |______________________________________________________|

	      Hexadecimal  numbers  must  always  start	 with  a
	      decimal  digit  (0-9).   The  hexadecimal	digits A
	      through F	can be given as	either	upper  or  lower
	      case.

	      The maximum number of digits in an integer depends
	      on  the  instruction  or	directive  in  which the
	      integer is used.

	      You can set the default radix by using the  .RADIX
	      directive.      See    the    section,	``.RADIX
	      Directive,'' in Chapter 9.

	      Examples















	      2-2



















					  Elements of the Assembler



		 01011010B 132Q	5AH  90D  90
		 01111B		17O  0FH  15D  15



		 2.4  Real Numbers

		 Syntax

		      digits.digitsE [ +|- ]digits

		 A  real  number  represents  a	 number	 having	 an
		 integer,  a fraction, and an exponent.	 The digits
		 can be	any combination	of decimal digits.   Digits
		 before	the decimal point (.) represent	the integer
		 part, and those  after	 the  point  represent	the
		 fraction.   The digits	after the exponent mark	(E)
		 represent the exponent.  The exponent is optional.
		 If  an	 exponent  is given, the plus (+) and minus
		 (-) signs can be used to indicate its sign.

		 Real numbers can be used only with the	DD, DQ,	and
		 DT  directives.   The	maximum	number of digits in
		 the number  and  the  maximum	range  of  exponent
		 values	depends	on the directive.

		 Examples















								2-3



















	      XENIX Macro Assembler Reference Manual



	      25.23	2.523E1	  2523.0E-2



	      2.5  Encoded Real	Numbers

	      Syntax

		   digitsR

	      An encoded real number is	an 8,  16,  or	20-digit
	      hexadecimal  number  that	represents a real number
	      in encoded format.  An encoded real number  has  a
	      sign  field,  a  biased  exponent, and a mantissa.
	      These values are encoded as bit fields within  the
	      number.	The  exact  size and meaning of	each bit
	      field depends on the number of bits in the number.
	      The digits must be hexadecimal digits.  The number
	      must begin with a	decimal	digit (0-9).

	      Encoded real numbers can be used only with the DD,
	      DQ,  and	DT  directives.	  The  maximum number of
	      digits for the encoded numbers used with	DD,  DQ,
	      and DT must be 8,	16, and	20 digits, respectively.
	      (If a leading zero is supplied, the number must be
	      9, 17, or	21 digits.)

	      Example














	      2-4



















					  Elements of the Assembler



		 3F800000	; 1.0 for DD
		 3FF0000000000000    ; 1.0 for DQ



		 2.6  Packed Decimal Numbers

		 Syntax

		      [+ | -] digits

		 A  packed  decimal  number  represents	 a  decimal
		 integer  that	is  to	be stored in packed decimal
		 format.  Packed decimal storage has a leading sign
		 byte  and  9 value bytes. Each	value byte contains
		 two decimal digits. The high-order bit	of the sign
		 byte  is 0 for	positive values, and 1 for negative
		 values.

		 Packed	decimals have  the  same  format  as  other
		 decimal  integers  except  that  they	can take an
		 optional plus (+) or minus (-)	 sign  and  can	 be
		 defined  only	with  the  DT  directive.  A packed
		 decimal must not have more than 18 digits.

		 Examples
















								2-5



















	      XENIX Macro Assembler Reference Manual



	      1234567890	  ; encoded as 00000000001234567890
	      -1234567890	  ; encoded as 80000000001234567890



	      2.7  Character and String	Constants

	      Syntax

		   ' characters	'	   " characters	"

	      A	character constant is a	constant composed  of  a
	      single  ASCII  character.	  A string constant is a
	      constant composed	of two or more ASCII characters.
	      The  constant  must be enclosed in matching single
	      quotation	or double quotation marks.

	      Single quotation marks must be encoded twice  when
	      given  in	 constants  that  are enclosed by single
	      quotation	 marks.	  Similarly,  double   quotation
	      marks   must   be	 encoded  twice	 when  given  in
	      constants	that are enclosed  by  double  quotation
	      marks.

	      Examples

		   'a'		       'ab'		     "a"
		   "This is a message."
		   'Can''t find	the file.'
		   "Specified ""value""	not found."












	      2-6



















					  Elements of the Assembler



		 2.8  Names

		 Syntax

		      characters...

		 A name	is a combination of  letters,  digits,	and
		 special characters that can be	used in	instruction
		 statements  to	 labels,  variables,  and  symbols.
		 Names have the	following formatting rules:

		 1.   A	 name  must  begin  with   a   letter,	 an
		      underscore (_), a	question mark (?), a dollar
		      sign ($),	or an at sign (@).

		 2.   A	name can have any combination of upper	and
		      lowercase	letters.  All lowercase	letters	are
		      converted	to uppercase unless the	-Ml or	-Mx
		      option is	used.

		 3.   A	name can have any number of characters,	but
		      only  the	 first 31 characters are used.	All
		      other characters are ignored.

		 Examples

		      subrout3	    Array      _main















								2-7



















	      XENIX Macro Assembler Reference Manual



	      2.9  Reserved Names

	      A	reserved name is any name that	has  a	special,
	      predefined  meaning  to  the  assembler.	Reserved
	      names include instruction	and directive mnemonics,
	      register	names,	and predefined group and segment
	      names.  These names can be used  only  as	 defined
	      and must not be redefined.

	      The following is a  list	of  all	 reserved  names
	      except instruction mnemonics.  For a complete list
	      of  instruction	mnemonics,   see   Appendix   A,
	      ``Instruction Summary.''

		 %OUT	   DQ	   IFIDN     QWORD
		 .186	   DS	   IFNB	     .RADIX
		 .286c	   DT	   IFNDEF    RECORD
		 .286p	   DW	   INCLUDE   REPT
		 .287	   DWORD   IRP	     .SALL
		 .8086	   DX	   IRPC	     SEG
		 .8087	   ELSE	   LABEL     SEGMENT
		 =	   END	   .LALL     .SFCOND
		 AH	   ENDIF   LE	     SHL
		 AL	   ENDM	   LENGTH    SHORT
		 AND	   ENDP	   .LFCOND   SHR
		 ASSUME	   ENDS	   .LIST     SI
		 AX	   EQ	   LOCAL     SIZE
		 BH	   EQU	   LOW	     SP
		 BL	   ES	   LT	     SS
		 BP	   EVEN	   MACRO     STRUC
		 BX	   EXITM   MASK	     SUBTTL
		 BYTE	   EXTRN   MOD	     TBYTE
		 CH	   FAR	   NAME	     .TFCOND
		 CL	   GE	   NE	     THIS
		 COMMENT   GROUP   NEAR	     TITLE
		 .CREF	   GT	   NOT	     TYPE
		 CS	   HIGH	   OFFSET    .TYPE
		 CX	   IF	   OR	     WIDTH
		 DB	   IF1	   ORG	     WORD
		 DD	   IF2	   PAGE	     .XALL



	      2-8


















					  Elements of the Assembler



		    DH	      IFB     PROC	.XCREF
		    DI	      IFDEF   PTR	.XLIST
		    DL	      IFDIF   PUBLIC	XOR
			      IFE     PURGE

		 All upper  and	 lowercase  combinations  of  these
		 names	are  considered	 to  be	the same name.	For
		 example, the names ``Length'' and  ``LENGTH''	are
		 the same name for the LENGTH operator.


		 2.10  Statements

		 Syntax

		      [	name ]	mnemonic  [ operands ]

		 A  statement  is  a  combination  of  a  name,	 an
		 instruction or	directive mnemonic, and	one or more
		 operands.  A statement	represents an action to	 be
		 taken	by  the	 assembler,  such  as  generating a
		 machine instruction or	one or more bytes of data.

		 Statements have the following formatting rules:

		 1.   A	statement can begin in any column.

		 2.   A	 statement  must  not  be  more	 than	128
		      characters  in length and	must not contain an
		      embedded	newline	 character.    This   means
		      continuing  a  statement on multiple lines is
		      not allowed.

		 3.   A	statement must be terminated by	 a  newline
		      character.   This	includes the last statement
		      in the source file.






								2-9



















	      XENIX Macro Assembler Reference Manual



	      Examples

		   count     db	  0		     mov  ax, bx
		   assume cs:_TEXT, ds:DGROUP
		   _main     proc far



	      2.11  Comments

	      Syntax

		   ;text

	      A	 comment  is  any  combination	 of   characters
	      preceded	by  a  semicolon (;) and terminated by a
	      newline  character.  Comments  let  a   programmer
	      describe	the  action  of	 a  program at the given
	      point.  Comments	are  otherwise	ignored	 by  the
	      assembler	and have no effect on assembly.

	      Comments can be  placed  anywhere	 in  a	program,
	      including	 on  the  same line as a statement.  The
	      comment must be placed after all names, mnemonics,
	      and  operands have been given.  A	comment	must not
	      be longer	than one line,	that  is,  it  must  not
	      contain any embedded newline characters.	For very
	      long comments, the COMMENT directive can be used.

	      Examples

		   ; This comment is alone on a	line.
			mov  ax, bx    ; This comment follows a	statement.
		   ; Comments can contain reserved words like PUBLIC.








	      2-10



















					  Elements of the Assembler



		 2.12  COMMENT Directive

		 Syntax

		      COMMENT delim  text  delim

		 The COMMENT directive causes  MASM  to	 treat	all
		 text  between the given pair of delimiters (delim)
		 as a comment.	The delimiter character	must be	the
		 first	 non-blank   character	after  the  COMMENT
		 keyword.  The text is all remaining characters	 up
		 to the	next occurrence	of the delimiter.  The text
		 must not contain the delimiter.

		 The  COMMENT  directive  is  typically	 used	for
		 multiple  line	comments.  Although text can appear
		 on the	same line as the last delimiter,  any  text
		 after the delimiter is	ignored.

		 Example

		      comment *
		      This comment continues until the
		      next asterisk.	   *

		      comment +		 The assembler ignores the
		      following	MOV statement	    + mov     ax, 1















							       2-11























	      Chapter 2


	      Elements of the Assembler
	      __________________________________________________



	      2.1  Introduction	 2-1

	      2.2  Character Set  2-1

	      2.3  Integers  2-1

	      2.4  Real	Numbers	 2-3

	      2.5  Encoded Real	Numbers	 2-4

	      2.6  Packed Decimal Numbers  2-5

	      2.7  Character and String	Constants  2-6

	      2.8  Names  2-7

	      2.9  Reserved Names  2-8

	      2.10 Statements  2-9

	      2.11 Comments  2-10

	      2.12 COMMENT Directive  2-11

























