.386

	; 	BEGINNING OF MICROSOT-32 CODE
     
.$$RESET_DS = 0
.$$CHECK_STACK = ._NO
.$$USE_286_INSTRUCTION_SET = ._YES
.$$ALWAYS_SET_NEW_STACK_FRAME = ._NO

.$$ALWAYS_SAVE_EBX = ._YES

.$$SAVE_SI = .$RSI;
.$$SAVE_DI = .$RDI;
.$$SAVE_ES = .$RES

.$$LATTICE_LONG = ._NO;
.$$FCN_BASE = 8800H 			; .xC_ARGS + .xLABEL
.$$UNDERSCORE = ._LEADING


.$$DISPLAY_COMPILER_AND_MEMORY_MODEL MACRO
	%OUT
	%OUT COMPILER ***** MICROSOFT C++ 32 ******
	IF (.$MEMORY_MODEL EQ ._FLAT_MODEL)
		%OUT MEMORY MODEL       ***** FLAT -- 386 Protected Mode *****
		ENDIF
	ENDM


.$$SET_MEM_MODEL MACRO
			
	IF (.$MEMORY_MODEL EQ ._FLAT_MODEL)
		CODE_PTR = ._SMALL_CODE_PTR;
		DATA_PTR = ._SMALL_DATA_PTR;
		.$$CODE_SIZE = ._SMALL_CODE;
		.$$DATA_SIZE = ._SMALL_DATA;
		.$$DFLT_DATA_ATTR = 0
		.$$DFLT_CODE_ATTR = .$$FCN_BASE
		EXITM
		ENDIF
		
	ENDM

	
.$$SET_CHECK_STACK MACRO
		
     IF ((.$$CHECK_STACK EQ ._YES) AND (.$$DATA_SIZE NE ._LARGE_DATA))
		EXTERN _INT _mwstack_limit;
		ENDIF
	
	ENDM
	
	
.$$SET_FCN_STACK_FRAME MACRO REG_LIST
	
	.@PUSH_N_BYTES = 0
	IF (.$FAR_DS NE 0)
		.@PUSH_N_BYTES = 4;
		ENDIF
	IF (.$$ALWAYS_SAVE_EBX EQ ._YES)
		PUSH	EBX
		.@PUSH_N_BYTES = 4;
		ENDIF
	IF ((.$$CHECK_STACK + .$$ALWAYS_SET_NEW_STACK_FRAME + .$N_FCN_ARG_BYTES + .$N_AUTO_BYTES) GT 0)
		PUSH	EBP
		MOV	EBP, ESP
	     .@PUSH_N_BYTES = .@PUSH_N_BYTES  + 4;
		.$NEW_STACK_FRAME = ._YES
;		IF (.$$CHECK_STACK EQ ._YES) 
;			IF (.$$DATA_SIZE NE ._LARGE_DATA)
;			     IF (.$$DATA_SIZE EQ ._SMALL_DATA)
;			     	cmp	sp, _mwstack_limit
;		     	ELSE
;			     	cmp	sp, ds:_mwstack_limit
;			     	ENDIF
;			ELSE
;			     cmp	sp, ss:-2
;				ENDIF
;		     jnb	LBL_1
;			INT  0
;		  	LBL_1:
;			ENDIF
		ENDIF

		IF (.$N_AUTO_BYTES GT 0) 
			SUB	ESP, .$N_AUTO_BYTES
			ENDIF
	
	.$PUSH_PROLOGUE_REGS <REG_LIST>
	
	IF ((.$N_AUTO_BYTES GT 0) OR (.$PUSH_N_REGS GT 0))
		.$BP_EQUALS_SP = ._NO;
		ENDIF
	
	.$FCN_ARG_BASE = .$FCN_RETURN_PTR_SZ + .@PUSH_N_BYTES
	
	ENDM

._HUGG_MODEL = -23

IF (@MASM_VER GE 60)
	OPTION NOKEYWORD:<FLAT>
ENDIF

DEFINE_DATA_SEG MACRO MODULE_NAME
	
	START_DATA	MACRO
		.386
		_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
		ENDM
		
     END_DATA		MACRO
     	_DATA ENDS
     	ENDM
	
		FLAT		GROUP     _DATA
		ASSUME    DS:FLAT
		DS_LBL	EQU		DS

	ENDM
		

		
.$$SINGLE_CODE_SEG = ._YES

DEFINE_CODE_SEG  MACRO   MODULE_NAME
		
	     .$$DEFINE_SEGMENTS 
	     ASSUME    CS:_TEXT
		CGROUP	GROUP _TEXT
		ASSUME	CS:CGROUP
		CS_LBL	EQU _TEXT
	ENDM
		

.$$DEFINE_SEGMENTS MACRO
	
	START_CODE  MACRO
          .386
          _TEXT SEGMENT DWORD USE32 'CODE' PUBLIC 
		ENDM
			
	END_CODE	MACRO
		_TEXT ENDS
		ENDM       
			
	ENDM


