;******************************* MODULE HEADER *******************************;
;*                                                                           *;
;* FILE: mc0_pm.asm                                                          *;
;*                                                                           *;
;* MACHINE: SGenNGen   LANGUAGE: ASSEMBLER  OS: CTOS                        *;
;*                                                                           *;
;* DESCRIPTION:  first.asm  CTOS segment ordering                           *;
;*                                                                           *;
;*	NOTE: MUST assemble with MX option for case sensitivity.                *;
;*                                                                           *;
;*		MASM MX MC0_PM.Asm                                                  *;
;*                                                                           *;
;*	Linked in first in order to get proper segment ordering.                 *;
;*                                                                           *;
;* HISTORY:                                                                  *;
;*                                                                           *;
;* MMDDYY VVVVMM PROGRAMMER    DESCRIPTION OF CHANGE (Most recent first) *;
;*                                                                           *;
;*	050792  SRE	Added __ctoserrno.                                       *;
;*	022792  SRE	Added a NOP to top of main so that we can at least       *;
;*					set a debug statement before running.                    *;
;*	121291  SRE	Converted _BUILDENV and __PREASTART to uppercase;        *;
;*					added comment about assembling with MX (for case        *;
;*					sensitivity).                                            *;
;*	112190  TAB	Added startup code.                                      *;
;*	100890  TAB	Reordered to match OS2 segment ordering.                *;
;*                                                                           *;
;* TITLE:  CTOS SYSTEM SOFTWARE                                              *;
;*                                                                           *;
;*            PROPRIETARY PROGRAM MATERIAL                                   *;
;*                                                                           *;
;* THIS MATERIAL IS PROPRIETARY TO UNISYS CORPORATION AND IS NOT TO BE       *;
;* REPRODUCED, USED OR DISCLOSED EXCEPT IN ACCORDANCE WITH PROGRAM LICENSE   *;
;* OR UPON WRITTEN AUTHORIZATION OF THE PATENT DIVISION OF UNISYS            *;
;* CORPORATION, DETROIT, MICHIGAN 48232, USA.                                *;
;*                                                                           *;
;* COPYRIGHT (C) 1980, 1993 CONVERGENT INCORPORATED. ALL RIGHTS RESERVED     *;
;* COPYRIGHT (C) 1980, 1993 UNISYS CORPORATION. ALL RIGHTS RESERVED          *;
;* ************************************************************************* *;
;*                                                                           *;
;* UNISYS BELIEVES THAT THE SOFTWARE FURNISHED HEREWITH IS ACCURATE AND      *;
;* RELIABLE, AND MUCH CARE HAS BEEN TAKEN IN ITS PREPARATION.  HOWEVER,      *;
;* NO RESPONSIBILITY, FINANCIAL OR OTHERWISE, CAN BE ACCEPTED FOR ANY        *;
;* CONSEQUENCES ARISING OUT OF THE USE OF THIS MATERIAL, INCLUDING LOSS OF   *;
;* PROFIT, INDIRECT, SPECIAL, OR CONSEQUENTIAL DAMAGES, THERE ARE NO         *;
;* WARRANTIES WHICH EXTEND BEYOND THE PROGRAM SPECIFICATION.                 *;
;*                                                                           *;
;* THE CUSTOMER SHOULD EXERCISE CARE TO ASSURE THAT USE OF THE SOFTWARE      *;
;* WILL BE IN FULL COMPLIANCE WITH LAWS, RULES AND REGULATIONS OF THE        *;
;* JURISDICTIONS WITH RESPECT TO WHICH IT IS USED.                           *;
;*                                                                           *;
;*                                                                           *;
;*************************** END OF MODULE HEADER ****************************;

; code segments first

_TEXT			SEGMENT		WORD PUBLIC 'CODE'
_TEXT			ENDS

C_ETEXT			SEGMENT		WORD PUBLIC 'ENDCODE'
C_ETEXT			ENDS

; nonDGroup'd segments follow.

FAR_BSS			SEGMENT		WORD PUBLIC 'FAR_BSS'
FAR_BSS			ENDS

; DGroup:  BEGDATA first

NULL			SEGMENT		WORD PUBLIC 'BEGDATA'
NULL			ENDS

; DGroup:  segments not of class BEGDATA, BSS, STACK or HEAP

DATA			SEGMENT		WORD PUBLIC 'DATA'
public	__ctoserrno
__ctoserrno	dw 0	; Used to report CTOS error code from file ops, etc.
DATA			ENDS

MEMORY			SEGMENT		WORD MEMORY 'MEMORY'
MEMORY			ENDS

CONST			SEGMENT		WORD PUBLIC 'CONST'
CONST			ENDS

MSG				SEGMENT		WORD PUBLIC 'MSG'
MSG				ENDS

; DGroup:  BSS before Stack

BSS				SEGMENT		WORD PUBLIC 'BSS'
public			_edata
_edata	label	byte
BSS				ENDS

___BSS			SEGMENT		WORD PUBLIC 'BSS'
public			_end
_end	label	byte
___BSS			ENDS

; DGroup:  Stack before Heap

STACK			SEGMENT		WORD STACK 'STACK'
PUBLIC StackBottom
StackBottom	LABEL WORD
STACK			ENDS

___STACK		SEGMENT		WORD PUBLIC 'STACK'
public			_end_stack
_end_stack	label	byte
___STACK		ENDS

; heap must be last so WinCreateHeap will work properly

HEAP			SEGMENT		WORD PUBLIC 'HEAP'
public			_st_heap
_st_heap	label	byte
HEAP			ENDS

___HEAP			SEGMENT		WORD PUBLIC 'HEAP'
public			_end_heap, _end_mem
_end_heap	label	byte
_end_mem	label	byte
___HEAP			ENDS

DGroup			group	NULL,DATA,MEMORY,CONST,MSG
DGroup			group	BSS,___BSS,STACK,___STACK,HEAP,___HEAP

; Microsoft C preinitialization
extrn	__PREASTART:far	; set up command line
extrn	_BUILDENV:far	; set up registers
extrn	__astart:far	; Microsoft C entry point

_TEXT			SEGMENT
assume		cs:_TEXT

PUBLIC		_main_pm
_main_pm	PROC	FAR

	NOP					; Added for debugging (can put Debug here)
	mov		ax, DGroup
	mov		ds, ax
	call	__PREASTART
	call	_BUILDENV
	call	__astart	; never exits

_main_pm	ENDP
_TEXT		ENDS

END	_main_pm
