





			     Segment Names For High-Level Languages



		 C.1  Introduction

		 This appendix	describes  the	naming	conventions
		 used  to  form	assembly language source files that
		 are compatible	with object modules produced by	the
		 Microsoft   C,	  Pascal,   and	  Fortran  language
		 compilers (version 3.0	or later).

		 High-level language  modules  have  the  following
		 four predefined segment types:

		      TEXT	      for program code
		      DATA	      for program data
		      BSS	      for uninitialized	space
		      CONST	      for constant data

		 Any assembly language source file that	 is  to	 be
		 assembled  and	 linked	 to  a	high-level language
		 module	must use these segments	as described in	the
		 following sections.

		 High-level  language  modules	also   have   three
		 different memory models:

		      Small	      for single code and data segments
		      Middle	      for multiple code	segment	but a single data segment
		      Large	      for multiple code	and data segments

		 Assembly language source files	to be assembled	for
		 a  given  memory  model  must	 use   the   naming
		 conventions given in the following sections.











								C-1



















	      XENIX Macro Assembler Reference Manual



	      C.2  Text	Segments

	      Syntax

		   name_TEXT	   SEGMENT BYTE	PUBLIC 'CODE'
				   statements
		   name_TEXT	   ENDS

	      A	text segment defines a	module's  program  code.
	      It  contains  statements	that define instructions
	      and data within the segment.  A text segment  must
	      have  the	 name  name_TEXT,  where name can be any
	      valid name.  For middle and large	module programs,
	      the  module's  own name is recommended.  For small
	      model programs, only ``_TEXT'' is	allowed.

	      A	 segment  can	contain	  any	combination   of
	      instructions    and    data   statements.	   These
	      statements must appear in	an order that creates  a
	      valid program. All instructions and data addresses
	      in a text	segment	are relative to	the  CS	 segment
	      register.	 Therefore, the	statement

		   assume cs: name_TEXT

	      must appear at the beginning of the segment.  This
	      statement	 ensures  that	each  label and	variable
	      declared in the segment will  be	associated  with
	      the CS segment register (see the section,	``ASSUME
	      Directive'' in Chapter 3).

	      Text segments must  have	``BYTE''  alignment  and
	      ``PUBLIC''  combination  type,  and  must	have the
	      class  name   ``CODE.''	These	define	 loading
	      instructions   that  are	passed	to  the	 linker.
	      Although other segment attributes	 are  available,
	      they   should   not   be	used.	For  a	complete
	      description of the attributes,  see  the	section,
	      ``SEGMENT	and ENDS Directives,'' in Chapter 3.



	      C-2



















			     Segment Names For High-Level Languages



		 Small Model Programs.	Only one  text	segment	 is
		 allowed.  The segment must not	exceed 64K bytes.

		 All procedure and statement labels must  have	the
		 NEAR type.

		 Example

		      _TEXT   segment byte public 'CODE'
			      assume cs:_TEXT
		      _main   proc near				  .
			      .		       .       _main   endp
		      _TEXT   ends


		 Middle	and Large Model	 Programs.   Multiple  text
		 segments  are	allowed, however, no segment can be
		 greater  than	64K  bytes.   To  distinguish	one
		 segment  from	another,  each	should have its	own
		 name.	Since most modules contain  only  one  text
		 segment,  the	module's name is often used as part
		 of the	text segment's	name.	All  procedure	and
		 statement  labels should have the FAR type, unless
		 they will only	be accessed from  within  the  same
		 segment.

		 Example

		      SAMPLE_TEXT     segment byte public 'CODE'
			      assume  cs:SAMPLE_TEXT
		      _main   proc    far			  .
			      .		       .       _main   endp
		      SAMPLE_TEXT     ends









								C-3



















	      XENIX Macro Assembler Reference Manual



	      C.3  Data	Segments - Near

	      Syntax

		   _DATA   SEGMENT WORD	PUBLIC 'DATA'
			   statements	   _DATA   ENDS


	      A	near data segment defines initialized data  that
	      is  in  the  segment  pointed to by the DS segment
	      register when the	program	starts	execution.   The
	      segment  is  ``near''  because  all  data	 in  the
	      segment is accessible without giving  an	explicit
	      segment value.  All programs have	exactly	one near
	      data segment.  Only large	model programs can  have
	      additional data segments.

	      A	near data segment's name must be ``_DATA.''  The
	      segment	can  contain  any  combination	of  data
	      statements defining variables to be  used	 by  the
	      program.	The segment must not exceed 64K	bytes of
	      data.  All  data	addresses  in  the  segment  are
	      relative	 to  the  predefined  group  ``DGROUP''.
	      Therefore, the statements

		   DGROUP  group _DATA
			   assume ds: DGROUP


	      must appear at the beginning of the segment. These
	      statements  ensure  that each variable declared in
	      the data segment will be associated  with	 the  DS
	      segment  register	 and  DGROUP  (see the sections,
	      ``ASSUME Directive'' and	``GROUP	 Directive''  in
	      Chapter 3).

	      Near data	segments must be ``WORD'' aligned,  must
	      have  ``PUBLIC''	combination  type, and must have
	      the class	 name  ``DATA.''  These	 define	 loading
	      instructions   that  are	passed	to  the	 linker.



	      C-4


















			     Segment Names For High-Level Languages



		 Although other	segment	attributes  are	 available,
		 they must not be used.	 For a complete	description
		 of the	attributes, see	the section, ``SEGMENT	and
		 ENDS Directives,'' in Chapter 3.

		 Example

		      DGROUP  group   _DATA
			      assume ds: DGROUP

		      _DATA   segment word public 'DATA'
		      count   dw      0
		      array   dw      10 dup(1)
		      string  db      "Type CANCEL then	press RETURN", 0ah, 0
		      _DATA   ends



		 C.4  Data Segments - Far

		 Syntax

		      name_DATA	      SEGMENT WORD PUBLIC 'FAR_DATA'
				      statements
		      name_DATA	      ENDS

		 A far data segment defines data or data space that
		 can  be  accessed  only  by specifying	an explicit
		 segment value.	 Only large model programs can have
		 far data segments.

		 A far data segment's name must	be name_DATA, where
		 name can be any valid name.  The name of the first
		 variable declared in the segment  is  recommended.
		 The  segment  can  contain any	combination of data
		 statements defining variables to be  used  by	the
		 program.  The segment must not	exceed 64K bytes of
		 data.	All  data  addresses  in  the  segment	are
		 relative   to	 the   ES  segment  register.  When
		 accessing a variable in a far data segment, the ES



								C-5


















	      XENIX Macro Assembler Reference Manual



	      register	must  be  set to the appropriate segment
	      value.  Also, the	segment	override  operator  must
	      be used with the variable's name (see the	section,
	      ``Attribute Operators'' in Chapter 5).

	      Far data segments	must be	``WORD''  aligned,  must
	      have  ``PUBLIC''	combination  type, and must have
	      the class	name ``FAR_DATA.'' These define	 loading
	      instructions   that  are	passed	to  the	 linker.
	      Although other segment attributes	 are  available,
	      they must	not be used.  For a complete description
	      of the attributes, see the section, ``SEGMENT  and
	      ENDS Directives,'' in Chapter 3.

	      Example

		   ARRAY_DATA	   segment word	public 'FAR_DATA'
		   array   dw	   0		       dw      1
			   dw	   2		       dw      4
		   table   dw	   1600	dup(?)
		   ARRAY_DATA	   ends



	      C.5  Bss Segments

	      Syntax

		   _BSS	   SEGMENT WORD	PUBLIC 'BSS'
			   statements	   _BSS	   ENDS

	      A	bss segment defines uninitialized data space.  A
	      bss  segment's  name must	be ``_BSS.'' The segment
	      can contain any  combination  of	data  statements
	      defining variables to be used by the program.  The
	      segment must  not	 exceed	 64K  bytes.   All  data
	      addresses	 in  the  segment  are	relative  to the
	      predefined  group	 ``DGROUP''.	Therefore,   the
	      statements



	      C-6



















			     Segment Names For High-Level Languages



		      DGROUP  group _BSS
			      assume ds: DGROUP

		 must appear at	the beginning of the segment. These
		 statements  ensure  that each variable	declared in
		 the bss segment will be  associated  with  the	 DS
		 segment  register  and	 DGROUP	 (see the sections,
		 ``ASSUME Directive'' and  ``GROUP  Directive''	 in
		 Chapter 3).

		 __________________________________________________
		 Note

		   The group name DGROUP must  not  be	defined	 in
		   more	 than one GROUP	directive in a source file.
		   If a	source file contains both a  DATA  and	BSS
		   segment, the	directive

			DGROUP	group  _DATA, _BSS

		   should be used.
		 __________________________________________________

		 A bss segment must be ``WORD''	aligned, must  have
		 ``PUBLIC''  combination  type,	 and  must have	the
		 class	 name	``BSS.''   These   define   loading
		 instructions	that  are  passed  to  the  linker.
		 Although other	segment	attributes  are	 available,
		 they must not be used.	 For a complete	description
		 of the	attributes, see	the section, ``SEGMENT	and
		 ENDS Directives,'' in Chapter 3.











								C-7



















	      XENIX Macro Assembler Reference Manual



	      Example

		   DGROUP  group   _BSS
			   assume ds: DGROUP

		   _BSS	   segment word	public 'BSS'
		   count   dw	   ?
		   array   dw	   10 dup(?)
		   string  db	   30 dup(?)	  _BSS	  ends



	      C.6  Constant Segments

	      Syntax

		   CONST  SEGMENT WORD PUBLIC 'CONST'
			   statements	   CONST  ENDS

	      A	constant segment defines constant data that will
	      not  change  during  program  execution.	Constant
	      segments	are  typically	used  in   large   model
	      programs	to  hold  the segment values of	far data
	      segments.

	      The constant segment's name must be ``CONST.'' The
	      segment	can  contain  any  combination	of  data
	      statements defining constants to be  used	 by  the
	      program.	 The  segment must not exceed 64K bytes.
	      All data addresses in the	segment	are relative  to
	      the  predefined  group ``DGROUP''.  Therefore, the
	      statements

		   DGROUP  group CONST
			   assume ds: DGROUP

	      must appear at the beginning of the segment. These
	      statements  ensure  that each variable declared in
	      the constant segment will	be associated  with  the
	      DS  segment register and DGROUP (see the sections,



	      C-8


















			     Segment Names For High-Level Languages



		 ``ASSUME Directive'' and  ``GROUP  Directive''	 in
		 Chapter 3).

		 __________________________________________________
		 Note

		   The group name DGROUP must  not  be	defined	 in
		   more	 than one GROUP	directive in a source file.
		   If a	source file contains a DATA, BSS, and CONST
		   segment, the	directive

			DGROUP	group  _DATA, _BSS, CONST

		   should be used.
		 __________________________________________________

		 A constant segment  should  be	 ``WORD''  aligned,
		 must  have  ``PUBLIC''	 combination type, and must
		 have  the  class  name	 ``CONST.''  These   define
		 loading   instructions	 that  are  passed  to	the
		 linker.  Although  other  segment  attributes	are
		 available,  they must not be used.  For a complete
		 description of	the attributes,	 see  the  section,
		 ``SEGMENT and ENDS Directives,'' in Chapter 3.

		 Example

		      DGROUP  group   CONST
			      assume ds: DGROUP

		      CONST   segment word public 'CONST'
		      seg1    dw      ARRAY_DATA
		      seg2    dw      MESSAGE_DATA
		      CONST   ends

		 In this example, the constant segment receives	the
		 segment   values   of	 two   far  data  segments:
		 ARRAY_DATA and	MESSAGE_DATA.  These data  segments
		 must be defined elsewhere in the module.



								C-9























	      Appendix C


	      Segment Names

	      For High-Level Languages
	      __________________________________________________



	      C.1  Introduction	 C-1

	      C.2  Text	Segments  C-2

	      C.3  Data	Segments - Near	 C-4

	      C.4  Data	Segments - Far	C-5

	      C.5  Bss Segments	 C-6

	      C.6  Constant Segments  C-8



































