





					    MASM: A Macro Assembler



		 2.1  Introduction

		 The XENIX Macro Assembler, MASM,  assembles  8086,
		 186,  and  286	 assembly language source files	and
		 creates  relocatable  object  files  that  can	 be
		 linked	 and  executed	under  the  XENIX operating
		 system.  This chapter explains	how to invoke  MASM
		 and  describes	 the  format  of  assembly listings
		 generated by MASM. For	a complete  description	 of
		 the  syntax of	assembly language source files,	see
		 the XENIX Macro Assembler Reference Manual.


		 2.2  Starting and Using MASM

		 This section explains how to start and	use MASM to
		 assemble your program source files.


		 2.2.1	Assembling a Source File

		 You can assemble a program source file	 by  typing
		 the  MASM  command name and the names of the files
		 you wish to process.  The  command  line  has	the
		 form

		      MASM [ options ] filename

		 The  options  can  be	any  combination  of   MASM
		 options. The options are described in Section 2.3,
		 ``Using MASM  Options.''  Options  can	 be  placed
		 anywhere on the command line.

		 The filename must be the name of the  source  file
		 to be assembled.

		 Unless	otherwise specified  MASM  uses	 a  default
		 filename  for	the  relocatable  object  code.	The
		 default filename is the same as the  source  file,
		 except	 that  the  filename  extension	is replaced



								2-1


















	      XENIX Macro Assembler User's Guide



	      with .o.

	      MASM also	uses a default filename	for the	 listing
	      file  (if	 requested).  The assembly listing lists
	      the assembled code for each source  statement  and
	      the  names  and  types  of  symbols defined in the
	      program.	If you do not request a	listing	by using
	      the  appropriate	option,	 MASM does not create an
	      assembly listing.	The default filename is	the same
	      as  the  source  file,  except  that  the	filename
	      extension	is replaced by .lst.


	      2.3  Using MASM Options

	      The MASM options	control	 the  operation	 of  the
	      assembler	 and  the  format of the output	files it
	      generates.

	      MASM has the following options:

	      -a      Alphabetical ordering for	segments
	      -Dsym   Define symbol
	      -d      Output a pass 1 listing
	      -e      Emulated floating	point instructions
	      -Ipath  Include file pathname
	      -l[file]	      Output listing to	file not default
	      -Ml     Preserve case sensitivity	in names
	      -Mu     Map all symbols to upper case
	      -Mx     Preserve case sensitivity	in externals
	      -n      Suppress symbol table listing
	      -o[file]	      Ouput object code	to file	not default
	      -r      Real floating point instructions
	      -v      Output verbose assembler statistics
	      -X      False conditional	listing	toggle
	      -x      List errors to standard error channel

	      You can place options anywhere on	a  MASM	 command
	      line.  An	option affects all relevant files in the
	      command line even	if the option appears at the end



	      2-2


















					    MASM: A Macro Assembler



		 of the	line.


		 2.3.1	Outputting Segments in Alphabetical Order

		 The -a	option directs MASM to place the  assembled
		 segments in alphabetical order	before copying them
		 to the	object file. If	this option is	not  given,
		 MASM  copies the segments in the order	encountered
		 in the	source file.

		 Example

		      masm -a file.s

		 This example creates  an  object  file	 ``file.o''
		 whose segments	are arranged in	alphabetical order.
		 Thus,	if  the	 source	 file  ``file.s''  contains
		 definitions  for  the segments	``DATA,'' ``CODE,''
		 and ``MEMORY,''  the  assembled  segments  in	the
		 object	file have the order ``CODE,'' ``DATA,''	and
		 ``MEMORY''.


		 2.3.2	Symbol Definition

		 The -D	option directs MASM to	define	the  symbol
		 appended  to  the  -D	flag as	a text macro with a
		 null value. (See the EQU directive  in	 the  XENIX
		 Macro	Assembler Reference Manual for a discussion
		 of text macros.)  The symbol will be defined  with
		 the  case  in	effect at that point in	the command
		 line.	Any number of -D switches can be used.	The
		 defined  symbol  can  be tested with the IFDEF	and
		 IFNDEF	directives during the assembly.

		 Example

		      masm -DSymbol file.s



								2-3



















	      XENIX Macro Assembler User's Guide



	      This example directs MASM	 to  define  the  symbol
	      Symbol   as   a  null  text  macro.   The	 default
	      conversion  to  uppercase	 will  occur   in   this
	      example.


	      2.3.3  Creating a	Pass 1 Listing

	      The -d option directs MASM to add	a pass 1 listing
	      to  the assembly listing file, making the	assembly
	      listing show the results of both assembler passes.
	      A	 pass  1 listing is typically used to locate and
	      understand program  phase	 errors.   Phase  errors
	      occur   when  MASM  makes	 assumptions  about  the
	      program in pass 1	that are not valid in pass 2.

	      The -d option does not create  a	pass  1	 listing
	      unless  you also direct MASM to create an	assembly
	      listing.	It does	direct	MASM  to  display  error
	      messages	for  both  pass	 1  and	 pass  2  of the
	      assembly,	even if	no assembly listing is created.

	      Example

		   masm	-d -l file.s

	      This example directs  MASM  to  create  a	 pass  1
	      listing  for  the	 source	 file  ``file.s''.   The
	      listing is placed	in the file ``file.lst''.


	      2.3.4  Creating Code For a Floating Point	Emulator

	      The -e option directs MASM  to  generate	floating
	      point  instruction  codes	that can be ``fixed'' up
	      at link time to software interrupts.

	      This is the default option under XENIX.  If a  287
	      is  present, the XENIX system changes the	software
	      interrupts into real  287	 instructions.	 If  the



	      2-4


















					    MASM: A Macro Assembler



		 chip  is  not	present, a software emulator in	the
		 XENIX system  is  used	 to  process  the  software
		 interrupts  as	 if  the  287  chip  were  actually
		 present.  The emulator	does not handle	 all  valid
		 287  instructions.   Unemulated  instructions will
		 give a	SIGILL signal.

		 Example

		      masm -e file.s

		 This example directs MASM to create emulation code
		 for  any  floating  point instructions	it finds in
		 the program.


		 2.3.5	Include	File Pathnames

		 The -I	option directs MASM to	use  the  specified
		 pathname as a prefix to the filenames given in	the
		 INCLUDE directives in an assembly program.  Up	 to
		 ten  -I  options  can	be specified on	the command
		 line.	To force searching of the current directory
		 in a specific order, -I.  can be used.

		 Example

		      masm -I /usr/include -I. file.s

		 This example  forces  the  INCLUDE  directives	 to
		 search	 /usr/include,	then the current directory,
		 for the given filename.


		 2.3.6	Produce	Listing	File

		 The -l	option directs MASM to generate	 a  listing
		 file to the standard output file, which is usually
		 to the	console	device.	  If  the  -l  flag  has  a
		 filename appended to it (of the form -llistfile ),



								2-5


















	      XENIX Macro Assembler User's Guide



	      then  the	 listing  is   written	 to   the   file
	      ``listfile''  rather than	the default listing file
	      whose name is the	same as	that of	the first  input
	      file except that it has the extension .lst.

	      Example

		   masm	-l file.s

	      This example directs MASM	to generate a listing in
	      the file ``file.lst''.

		   masm	-llist file.s

	      This example directs MASM	to generate a listing in
	      the file ``list''.


	      2.3.7  Preserving	Lowercase Names

	      The -Ml option directs MASM to preserve  lowercase
	      letters  in  label,  variable,  and  symbol names.
	      This means names that have the same  spelling  but
	      use  different case letters are considered unique.
	      For example, with	the  -Ml  option,  ``DATA''  and
	      ``data''	are  unique.   Under  XENIX  this is the
	      default case mapping option.

	      The -Ml option is	typically  used	 when  a  source
	      file  is	to be linked with object modules created
	      by a case-sensitive compiler.

	      Example

		   masm	-Ml file.s

	      This example directs MASM	 to  preserve  lowercase
	      letters  in  any	names defined in the source file
	      ``file.s''.



	      2-6



















					    MASM: A Macro Assembler



		 2.3.8	Converting Names To Uppercase

		 The -Mu option	directs	MASM to	convert	all letters
		 in all	symbols	to uppercase.

		 The -Mu option	overrides the -Ml and  -Mx  options
		 if used in the	same command line.

		 Example

		      masm -Mu file.s

		 This example directs  MASM  to	 convert  lowercase
		 letters  in  any  names defined in the	source file
		 ``file.s''.


		 2.3.9	Preserving Lowercase in	Public and External
			Names

		 The -Mx option	directs	MASM to	preserve  lowercase
		 letters  in  public  and  external names only when
		 copying these names to	the object file.   For	all
		 other	 purposes,   MASM  converts  the  lowercase
		 letters to uppercase.

		 Public	and external names are any label, variable,
		 or  symbol  names that	have been defined using	the
		 EXTRN or PUBLIC directives.  Since  MASM  converts
		 the letters to	uppercase for assembly,	these names
		 must have unique spellings.  That  is,	 the  names
		 ``DATA'' and ``Data'' are not unique.

		 The -Mx option	is used	to ensure that the names of
		 routines  or variables	copied to the object module
		 have the correct spelling.   The  option  is  used
		 with  any  source  file  that is to be	linked with
		 object	 modules  created   by	 a   case-sensitive
		 compiler,   and   is	particularly   useful	for
		 transporting assembler	files from MS-DOS to  XENIX



								2-7


















	      XENIX Macro Assembler User's Guide



	      when working with	C.

	      The -Mx option overrides the -Ml	option	if  both
	      are used in the same command line.

	      Example

		   masm	-Mx file.s

	      This example directs MASM	 to  preserve  lowercase
	      letters in any public or external	names defined in
	      the source file ``file.s''.


	      2.3.10  Suppress Symbol Table Information

	      The -n option directs MASM to suppress information
	      about  the  symbols used in the assembled	program.
	      For this option to take effect, the -l option must
	      also be used.

	      Example

		   masm	-l -n file.s

	      This example directs MASM	to  generate  a	 listing
	      file  without  any  symbol information in	the file
	      ``file.lst''.


	      2.3.11  Output Object Code

	      The -o option directs MASM to generate  an  object
	      code  file. If the -o flag has a filename	appended
	      to it (of	the form -oobjfile ),  then  the  object
	      code  is	written	 to  the file ``objfile'' rather
	      than the default file whose name is  the	same  as
	      that  of	the  first input file except that it has
	      the  extension  .o.   The	 -o  option  without   a
	      filename	suppresses  the	 generation of an object



	      2-8


















					    MASM: A Macro Assembler



		 file.

		 Example

		      masm -oObj file.s

		 This example directs MASM to generate object  code
		 in the	file ``Obj''.


		 2.3.12	 Creating  Code	 For   a   Floating   Point
			 Processor

		 The -r	option directs MASM  to	 generate  floating
		 point	instruction code that can be executed by an
		 8087 or 287 coprocessor.  Programs  created  using
		 the  -r  option can run only on machines having an
		 8087 or 287 coprocessor.

		 Example

		      masm -r file.s

		 This example directs MASM to assemble	the  source
		 file  ``file.s''  and	create	actual	8087 or	287
		 instruction code for floating point instructions.


		 2.3.13	 Output	Assembler Statistics

		 The -v	option directs MASM to print the number	 of
		 source	 lines,	 the number of lines assembled,	the
		 number	of symbols  in	addition  to  the  standard
		 statistics of bytes of	symbol space available,	and
		 the number of warning and severe errors.

		 Example

		      masm -vfile.s



								2-9



















	      XENIX Macro Assembler User's Guide



	      This  example  directs  MASM  to	give  additional
	      assembly statistics.


	      2.3.14  Suppressing False	Conditionals in	 Listing
		      Files

	      The -X option directs MASM to suppress copying  to
	      the  assembly  listing  all statements forming the
	      body of  an  IF  directive  whose	 expression  (or
	      condition) evaluates to false.  If you do	not give
	      the -X option in the command line, MASM lists  all
	      such  statements.	 The -X	option lets you	suppress
	      conditionals that	 do  not  generate  code.   This
	      option applies to	all IF directives: IF, IFE, IF1,
	      IF2, IFDEF, IFNDEF, IFB, IFNB, IFIDN, and	IFDIF.

	      The -X option  behaves  like  an	initial	 .TFCOND
	      directive	 in  a	source	file.	The  .SFCOND and
	      .LFCOND directives supercede  the	 -X  option  and
	      .TFCOND  directive.  See the XENIX Macro Assembler
	      Reference	Manual for a complete discussion of  the
	      .TFCOND, .SFCOND,	.LFCOND	directives.

	      The -X option does not affect the	assembly listing
	      unless  you  direct  MASM	 to  create  an	assembly
	      listing file.

	      Example

		   masm	-X -l file.s

	      If the source file ``file.s'' does not  contain  a
	      .TFCOND  directive,  this	 example directs MASM to
	      suppress all false conditionals it  finds	 in  the
	      source file.






	      2-10



















					    MASM: A Macro Assembler



		 2.3.15	 Output	Error Messages

		 The -x	option directs MASM to print error messages
		 on  the standard error	channel, in addition to	the
		 messages generated in the  listing  file,  without
		 displaying the	the source line	in error.  If -l is
		 given,	then the -x option has no effect.  By using
		 this  option  the  assembler will assemble faster.
		 Error messages	can  be	 completely  suppressed	 by
		 using	 the   -x  option  which  makes	 assemblies
		 ``silent,'' i.e. sending no output to STDERR.

		 Example

		      masm -x file.s

		 This example directs MASM to print copies of error
		 messages only,	written	to the standard	error file.


		 2.4  Reading the Assembly Listing

		 MASM creates an assembly listing  of  your  source
		 file	whenever   you	give  an  assembly  listing
		 filename on the MASM command line.   The  assembly
		 listing  contains a list of the statements in your
		 program and the object	 code  generated  for  each
		 statement.   The  listing also	lists the names	and
		 values	of all labels, variables,  and	symbols	 in
		 your source file.  MASM creates one or	more tables
		 for macros, structures, records, segments, groups,
		 and  other  symbols and places	these tables at	the
		 end of	the assembly listing.

		 MASM lists symbols only if it	encounters  any	 in
		 the  program.	If  there  are	no  symbols in your
		 program for a particular table, the given table is
		 omitted.   For	 example,  if  you use no macros in
		 your program, you will	not see	a macro	section	 in
		 the symbol table.



							       2-11


















	      XENIX Macro Assembler User's Guide



	      The  assembly  listing  will  also  contain  error
	      messages	if  any	 errors	 occur	during assembly.
	      MASM places the messages below the statements that
	      caused  the  errors.   At	 the end of the	listing,
	      MASM displays the	 number	 of  error  and	 warning
	      messages it issued.

	      The following sections explain the format	 of  the
	      assembly	 listing  and  the  meaning  of	 special
	      symbols used in the listing.


	      2.4.1  Reading Program Code

	      MASM lists the program  code  generated  from  the
	      statements  of  a	 source	file.  Each line has the
	      form:

		   [line-number]  offset   code	  statement

	      The line-number is from the first	statement in the
	      assembly listing.	 The line numbers are given only
	      if a cross reference file	is also	 being	created.
	      The offset is the	offset from the	beginning of the
	      current segment to the  code.   The  code	 is  the
	      actual  instruction code or data generated by MASM
	      for the statement.  MASM gives the actual	 numeric
	      value  of	 the  code  if	possible.  Otherwise, it
	      indicates	what action needs to be	taken to compute
	      the  value.  The statement is the	source statement
	      shown exactly as it appears in the source	file, or
	      after   processing   by  a  MACRO,  IRP,	or  IRPC
	      directive.

	      If any errors occur  during  assembly,  the  error
	      message	will   be  printed  directly  below  the
	      statement	where the error	occurred, displaying the
	      source  file  and	 line  number in addition to the
	      error number and error message.



	      2-12



















					    MASM: A Macro Assembler



		 MASM uses  the	 following  special  characters	 to
		 indicate addresses that need to be resolved by	the
		 linker	or values that were generated in a  special
		 way:

		 Character   Meaning

		 R	     Relocatable address; linker must resolve
		 E	     External address; linker must resolve
		 ----	     Segment/group address; linker must	resolve
		 =	     EQU or = directive
		 nn:	     Segment override in statement
		 nn/	     REP or LOCK prefix	instruction
		 nn [ xx ]   DUP expression; nn	copies of the value xx
		 +	     Macro expansion
		 C	     Included line from	INCLUDE	file


		 Example























							       2-13



















	      XENIX Macro Assembler User's Guide



	      XENIX Macro Assembler	    Page 1-1	11-01-84

				  extrn	go:near

		     0000	       data segment public 'DATA'
				       assume es:data
		     0000 0002	       s2   dw	 2
		     0002	       data ends

		     0000	       code segment public 'CODE'
				       assume cs:code
		     0000	       start:
		     0000 E8 0000 E		 call go
		     0003 36:A1	0000 R	    mov	 ax, s2
		     0007 B4 4C		    mov	 ah, 4ch
		     0009 CD 21		    int	 21h
		     000B		    code ends

				       end




	      2.4.2  Reading a Macro Table

	      MASM lists the  names  and  sizes	 of  all  macros
	      defined  in  a  source  file.   The  list	 has two
	      columns: Name and	Length.

	      The Name column lists the	 names	of  all	 macros.
	      The names	are listed in alphabetical order and are
	      spelled exactly  as  given  in  the  source  file.
	      Names longer than	31 characters are truncated.

	      The Length column	lists the size of the  macro  in
	      terms   of  non-blank  lines.   This  size  is  in
	      hexadecimal.





	      2-14



















					    MASM: A Macro Assembler



		 Example


			Name	 Length
		      BIOSCALL	 0002		 DISPLAY    0005
		      DOSCALL	 0002		 KEYBOARD   0003
		      LOCATE	 0003	      SCROLL	 0004




		 2.4.3	Reading	a Structure and	Record Table

		 MASM  lists  the  names  and  dimensions  of	all
		 structures  and  records  in  a  source file.	The
		 table contains	two sets  of  overlapping  columns.
		 The  Width and	# Fields list information about	the
		 structure or record.  The Shift, Width, Mask,	and
		 Initial   columns   list   information	 about	the
		 structure or record members.

		 The Name column lists the names of all	 structures
		 and  records. The names are listed in alphabetical
		 order and are spelled	exactly	 as  given  in	the
		 source	 file.	Names longer than 31 characters	are
		 truncated.

		 For a structure, the Width column lists  the  size
		 (in  bytes) of	the structure.	The # Fields column
		 lists the number of fields in the structure.  Both
		 values	are in hexadecimal.

		 For fields of structures, the Shift  column  lists
		 the  offset  (in  bytes) from the beginning of	the
		 structure  to	the  field.   This  value   is	 in
		 hexadecimal.  The other columns are not used.






							       2-15



















	      XENIX Macro Assembler User's Guide



	      Example

			Name	  Width	    # Fields
				  Shift	    Width     Mask Initial

		   PARMLIST	  001C 0004
		      BUFSIZE	       0000
		      NAMESIZE	       0001
		      NAMETEXT	       0002
		      TERMINATOR       001B

	      For a record, the	Width column lists the size  (in
	      bits)  of	 the  record.  The # Fields column lists
	      the number of fields in the record.

	      For fields in a record, the Shift	count lists  the
	      offset  (in  bits) from the lower	order bit of the
	      record to	the first bit in the field.   The  Width
	      column lists the number of bits in the field.  The
	      Mask column lists	the maximum value of the  field,
	      expressed	 in  hexadecimal.   The	 Initial  column
	      lists the	initial	value of the field, if any.  For
	      each  field,  the	table shows the	mask and initial
	      values as	if they	were placed in	the  record  and
	      all other	fields were set	to 0.

	      Example

			Name	  Width	    # Fields
				  Shift	    Width     Mask Initial

		   REC0		  0008 0003
			FLD1	  0006 0002 00C0 0040
			FLD2	  0003 0003 0038 0000
			FLD3	  0000 0003 0007 0003
		   REC1		  000B 0002
			FL1	  0003 0008 07F8 0400
			FL2	  0000 0003 0007 0002




	      2-16



















					    MASM: A Macro Assembler



		 2.4.4	Reading	a Segment and Group Table

		 MASM lists the	names, sizes, and attributes of	all
		 segments  and	groups	in a source file.  The list
		 has five columns: Name, Size, Align, Combine,	and
		 Class.

		 The Name column lists the names  of  all  segments
		 and  groups.  The  names  in the list are given in
		 alphabetical  order,  except  that  the  names	 of
		 segments belonging to a group are placed under	the
		 group name. Names are spelled exactly as given	 in
		 the  source  file. Names longer than 31 characters
		 are truncated.

		 The Size column lists the size	(in bytes) of  each
		 segment.  Since a group has no	size, only the word
		 GROUP	is  shown.   The  size,	 if  given,  is	 in
		 hexadecimal.

		 The Align column lists	the alignment type  of	the
		 segment.  The types can be any	of the following:

		      BYTE	WORD	  PARA	    PAGE

		 If  the  segment  is  defined	with  no   explicit
		 alignment  type,  MASM	lists the default alignment
		 for that segment.

		 The Combine column lists the combine type  of	the
		 segment.    The  types	 can  be  any  one  of	the
		 following:

		      NONE	  PUBLIC	STACK	     MEMORY
		      COMBINE

		 NONE is given	if  no	explicit  combine  type	 is
		 defined  for  the  segment.   NONE  represents	the
		 private combine type.



							       2-17



















	      XENIX Macro Assembler User's Guide



	      The Class	column	lists  the  class  name	 of  the
	      segment.	 The name is spelled exactly as	given in
	      the source file.	If no name  is	given,	none  is
	      shown.

	      Example


		       Name	  Size	  Align	  Combine     Class

		   AAAXQQ	  0000	  WORD	  NONE	    'CODE'
		   DGROUP	  GROUP
		      DATA	  0024	  WORD	  PUBLIC    'DATA'
		      STACK	  0014	  WORD	  STACK	    'STACK'
		      CONST	  0000	  WORD	  PUBLIC    'CONST'
		      HEAP	  0000	  WORD	  PUBLIC    'MEMORY'
		      MEMORY	  0000	  WORD	  PUBLIC    'MEMORY'
		   ENTXCM	  0037	  WORD	  NONE	    'CODE'
		   MAIN_STARTUP	  007E	  PARA	  NONE	    'MEMORY'




	      2.4.5  Reading a Symbol Table

	      MASM  lists  the	 names,	  types,   values,   and
	      attributes of all	symbols	in the source file.  The
	      table has	four columns:  Name,  Type,  Value,  and
	      Attr.

	      The Name column lists the	names  of  all	symbols.
	      The  names  in  the list are given in alphabetical
	      order and	are spelled  exactly  as  given	 in  the
	      source  file.  Names longer than 31 characters are
	      truncated.

	      The Type column lists each symbol's type.	 A  type
	      is given as one of the following:




	      2-18



















					    MASM: A Macro Assembler



		      L	NEAR	a near label
		      L	FAR	     a far label
		      N	PROC	a near procedure label
		      F	PROC	a far procedure	label
		      Number	     an	absolute label
		      Alias	     an	alias for another symbol
		      Opcode	     an	instruction opcode
		      Text	a memory operand, string, or other value

		 If Type is Number, Opcode,  Alias,  or	 Text,	the
		 symbol	 is  defined  by  an  EQU directive or an =
		 directive.   The  Type	 column	 also	lists	the
		 symbol's length if it is known.  A length is given
		 as one	of the following:

		      BYTE	one byte (8-bits)
		      WORD	one word  (16-bits)
		      DWORD	doubleword (2 words)
		      QWORD	quadword (4 words)
		      TBYTE	     ten-bytes	(5 words)

		 A length can also be given as a number.   In  this
		 case,	the  symbol  is	a structure, and the number
		 defines the length (in	bytes)	of  the	 structure.
		 For example, the type

		      L	0031

		 identifies a label to a structure that	is 31 bytes
		 long.

		 The Value column shows	the numeric  value  of	the
		 symbol.    For	  absolute   symbols,	the   value
		 represents an	absolute  number.  For	labels	and
		 variable  names,  the value represents	that item's
		 offset	from the beginning of the segment in  which
		 it  is	defined.  If Type is Number, Opcode, Alias,
		 or Text,  the	Value  column  shows  the  symbol's
		 ``value,''  even  if the ``value'' is simple text.
		 Number	shows a	 constant  numeric  value.   Opcode



							       2-19


















	      XENIX Macro Assembler User's Guide



	      shows  a	blank  (the  symbol  is	 an alias for an
	      instruction mnemonic).  Alias shows  the	name  of
	      another  symbol.	 Text  shows  the  ``text''  the
	      symbol represents.  Text is any operand that  does
	      not fit one of the other three categories.

	      The  Attr	 column	 lists	the  attributes	 of  the
	      symbol.	The  attributes	 include the name of the
	      segment in which the symbol is  defined,	if  any,
	      the  scope  of the symbol, and the code length.  A
	      symbol's scope is	given  only  if	 the  symbol  is
	      defined using the	EXTRN or PUBLIC	directives.  The
	      scope can	be External or Global.	The code  length
	      is given only for	procedures.

	      Example

		   Symbols:


		   Name	   Type	      Value	   Attr

		   SYM	  Number    0005
		   SYM1	  Text	    1.234
		   SYM2	  Number    0008
		   SYM3	  Alias	    SYM4
		   SYM4	  Text	    5[BP][DI]
		   SYM5	  Opcode
		   SYM6	  L BYTE    0002	DATA
		   SYM7	  L WORD    0012	DATA Global
		   SYM8	  L DWORD   0022	DATA
		   SYM9	  L QWORD   0000	External
		   LAB0	  L FAR	    0000	External
		   LAB1	  L NEAR    0010	CODE








	      2-20



















					    MASM: A Macro Assembler



		 2.4.6	Reading	a Pass 1 Listing

		 When you specify the -d option	in the MASM command
		 line,	MASM  adds a pass 1 listing to the assembly
		 listing file, making the  listing  file  show	the
		 results  of both assembler passes.  The listing is
		 intended  to  help  locate  the  source  of  phase
		 errors.

		 The  following	 examples  illustrate  the  pass  1
		 listing  for  a source	file that assembled without
		 error.	 Although an error was produced	on pass	 1,
		 MASM  corrected  the error on pass 2 and completed
		 assembly correctly.

		 During	pass 1,	a  JLE	instruction  to	 a  forward
		 reference produces an error message:

























							       2-21



















	      XENIX Macro Assembler User's Guide



	      0017 7E 00	  JLE  SMLSTK
	      file(line) : error 9: Symbol not defined SMLSTK
	      0019 BB 1000	  MOV  BX,4096
	      001C	SMLSTK:


	      MASM displays this error	since  it  has	not  yet
	      encountered the definition for the symbol	SMLSTK.

	      By pass 2, SMLSTK	has been defined  and  MASM  can
	      fix the instruction so no	error occurs:































	      2-22



















					    MASM: A Macro Assembler



		 0017 7E 03	     JLE  SMLSTK
		 0019 BB 1000	     MOV  BX,4096
		 001C	   SMLSTK:


		 The JLE instruction's code now	contains 03 instead
		 of 00.	 This is a jump	of 3 bytes.

		 Since MASM generated the same amount of  code	for
		 both passes, there was	no phase error.	 If a phase
		 error had occurred, MASM would	have  displayed	 an
		 error message.

		 In the	 following  program  fragment,	a  mistyped
		 label	creates	a phase	error: In pass 1, the label
		 ``go''	is used	in a forward reference and  creates
		 a  ``Symbol not defined'' error. MASM assumes that
		 the symbol will be  defined  later  and  generates
		 three	bytes  of code,	reserving two bytes for	the
		 symbol's actual value.






















							       2-23



















	      XENIX Macro Assembler User's Guide



	      0000	     code segment
	      0000 E9 0000  U	       jmp  go
	      file(line) : error 9: Symbol not defined go
	      0003	go   label     byte
	      0003 B8 0001	  mov  ax, 1

	      0006	     code ends


	      In pass 2, the label ``go'' is known to be a label
	      of  BYTE type which is an	illegal	type for the JMP
	      instruction. As a	result,	MASM produces  only  two
	      bytes  of	code in	pass 2,	one less than in pass 1.
	      The result is a phase error.




























	      2-24



















					    MASM: A Macro Assembler



		 0000		code segment
		 0003 R		     jmp  go
		 file(line) : error 57:Illegal size for	item
		 0003	   go	label	  byte
		 file(line) : error 6: Phase error between passes
		 0003 B8 0001	     mov  ax, 1
		 0006		code ends



































							       2-25























	      Chapter 2


	      MASM:

	      A	Macro Assembler
	      __________________________________________________



	      2.1  Introduction	 2-1

	      2.2  Starting and	Using MASM  2-1
		   2.2.1  Assembling a Source File  2-1

	      2.3  Using MASM Options  2-2
		   2.3.1  Outputting  Segments	in  Alphabetical
	                  Order  2-3
		   2.3.2  Symbol Definition  2-4
		   2.3.3  Creating a Pass 1 Listing  2-4
		   2.3.4  Creating Code	 For  a	 Floating  Point
	                  Emulator  2-5
		   2.3.5  Include File Pathnames  2-6
		   2.3.6  Produce Listing File	2-6
		   2.3.7  Preserving Lowercase Names  2-7
		   2.3.8  Converting Names To Uppercase	 2-7
		   2.3.9  Preserving  Lowercase	 in  Public  and
	                  External Names  2-8
		   2.3.10 Suppress Symbol Table	Information  2-9
		   2.3.11 Output Object	Code  2-9
		   2.3.12 Creating Code	 For  a	 Floating  Point
	                  Processor  2-10
		   2.3.13 Output Assembler Statistics  2-10
		   2.3.14 Suppressing  False   Conditionals   in
	                  Listing Files  2-11
		   2.3.15 Output Error Messages	 2-11

	      2.4  Reading the Assembly	Listing	 2-12
		   2.4.1  Reading Program Code	2-13
		   2.4.2  Reading a Macro Table	 2-15


























		      2.4.3  Reading   a   Structure   and   Record
		             Table  2-16
		      2.4.4  Reading a Segment and Group Table	2-18
		      2.4.5  Reading a Symbol Table  2-19
		      2.4.6  Reading a Pass 1 Listing  2-22



















































