	; 	BEGINNING OF TURBO C CODE
     
.$$RESET_DS = 0
.$$CHECK_STACK = ._NO
.$$USE_286_INSTRUCTION_SET = ._NO;
.$$ALWAYS_SET_NEW_STACK_FRAME = ._NO

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

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

.$$DISPLAY_COMPILER_AND_MEMORY_MODEL MACRO
	%OUT
	%OUT COMPILER    ***** TURBO C *****
	IF (.$MEMORY_MODEL EQ ._SMALL_MODEL)
		%OUT MEMORY MODEL ***** SMALL *****
		ENDIF
	IF (.$MEMORY_MODEL EQ ._MEDIUM_MODEL)
		%OUT MEMORY MODEL  ***** MEDIUM *****
		ENDIF
	IF (.$MEMORY_MODEL EQ ._COMPACT_MODEL)
		%OUT MEMORY MODEL  ***** COMPACT *****
		ENDIF
	IF (.$MEMORY_MODEL EQ ._LARGE_MODEL)
		%OUT MEMORY MODEL  ***** LARGE *****
		ENDIF
	IF (.$MEMORY_MODEL EQ ._HUGE_MODEL)
		%OUT MEMORY MODEL  ***** HUGE *****
		ENDIF
	ENDM

.$$SET_MEM_MODEL MACRO
			
	IF (.$MEMORY_MODEL EQ ._SMALL_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
		
	IF (.$MEMORY_MODEL EQ ._MEDIUM_MODEL)
		CODE_PTR = ._LARGE_CODE_PTR;
		DATA_PTR = ._SMALL_DATA_PTR;
		.$$CODE_SIZE = ._LARGE_CODE;
		.$$DFLT_DATA_ATTR = 0
		.$$DFLT_CODE_ATTR = .xFAR + .$$FCN_BASE
		.$$DATA_SIZE = ._SMALL_DATA;
		EXITM
		ENDIF
	
	IF (.$MEMORY_MODEL EQ ._COMPACT_MODEL)
		CODE_PTR = ._SMALL_CODE_PTR;
		DATA_PTR = ._LARGE_DATA_PTR;
		.$$CODE_SIZE = ._SMALL_CODE;
		.$$DATA_SIZE = ._MEDIUM_DATA;
		.$$DFLT_DATA_ATTR = 0
		.$$DFLT_CODE_ATTR = .$$FCN_BASE
	     .$$SAVE_ES = 0
		EXITM
		ENDIF
	
	IF (.$MEMORY_MODEL EQ ._LARGE_MODEL)
		CODE_PTR = ._LARGE_CODE_PTR;
		DATA_PTR = ._LARGE_DATA_PTR;
		.$$CODE_SIZE = ._LARGE_CODE;
		.$$DATA_SIZE = ._MEDIUM_DATA;
		.$$DFLT_DATA_ATTR = 0
		.$$DFLT_CODE_ATTR = .xFAR + .$$FCN_BASE
	     .$$SAVE_ES = 0
	     EXITM
	     ENDIF                   
	
	IF (.$MEMORY_MODEL EQ ._HUGE_MODEL)
		CODE_PTR = ._LARGE_CODE_PTR;
		DATA_PTR = ._LARGE_DATA_PTR;
		.$$CODE_SIZE = ._LARGE_CODE;
		.$$DATA_SIZE = ._MEDIUM_DATA;
		.$$DFLT_DATA_ATTR = 0
		.$$DFLT_CODE_ATTR = .xFAR + .$$FCN_BASE
	     .$$SAVE_ES = 0
	     EXITM
	     ENDIF                   
	
	ENDM
	
.$$SET_CHECK_STACK MACRO
		
     IF (.$$CHECK_STACK EQ ._YES)
		extrn OVERFLOW@:far
	     IF (.$$DATA_SIZE EQ ._SMALL_DATA)
	     	EXTERN _INT __brklvl;
	     ELSE
	     	EXTERN _INT _stklen;
	     	ENDIF
		ENDIF
	
	ENDM
	
	
.$$SET_FCN_STACK_FRAME MACRO REG_LIST
	LOCAL LBL_1
	
	.@PUSH_N_BYTES = 0
	IF (.$FAR_DS NE 0)
		.@PUSH_N_BYTES = 2;
		ENDIF
	IF ((.$$CHECK_STACK + .$$ALWAYS_SET_NEW_STACK_FRAME + .$N_FCN_ARG_BYTES + .$N_AUTO_BYTES) GT 0)
		PUSH	BP
		MOV	BP, SP
	     .@PUSH_N_BYTES = .@PUSH_N_BYTES  + 2;
		.$NEW_STACK_FRAME = ._YES
		
		IF (.$N_AUTO_BYTES GT 0) 
			IF (.$N_AUTO_BYTES EQ 2)
				DEC	SP
				DEC	SP
			ELSE
				SUB	SP, .$N_AUTO_BYTES
				ENDIF
			ENDIF			
			
		IF (.$$CHECK_STACK EQ ._YES) 
			IF (.$$DATA_SIZE EQ ._SMALL_DATA)
			     .IF __brklvl BL sp, then_goto LBL_1
			ELSE
			     .IF _stklen AB sp, then_goto LBL_1
				ENDIF
			CALL FAR PTR OVERFLOW@
		  	LBL_1:
			ENDIF
		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


DEFINE_DATA_SEG MACRO
	
	START_DATA	MACRO
		_DATA SEGMENT WORD PUBLIC 'DATA'
		ENDM
		
     END_DATA		MACRO
     	_DATA ENDS
     	ENDM
	
	DGROUP    GROUP     _DATA
	ASSUME    DS:DGROUP
	DS_LBL	EQU		DGROUP
	
	ENDM
		
		
DEFINE_CODE_SEG  MACRO   MODULE_NAME
		
	IF (.$$CODE_SIZE EQ ._SMALL_CODE)
		.$$DEFINE_CODE_SEG _TEXT
	ELSE
	     .$$DEFINE_CODE_SEG _EZ_TEXT
	     ENDIF
	ENDM
		

.$$DEFINE_CODE_SEG MACRO MODULE_NAME
	
	CS_LBL 		EQU 		MODULE_NAME
	START_CODE  MACRO
          MODULE_NAME SEGMENT   BYTE PUBLIC 'CODE'
		ENDM
			
	END_CODE	MACRO
		MODULE_NAME ENDS
		ENDM       
	ASSUME    CS:MODULE_NAME
			
	ENDM





