	model	large compiler_text,pascal
	include	compiler.inc

	.data

	extrn	CurRegs:dword

	.code	compiler_text

	public	StdFunction

StdFunction	proc	near
	les	bx,CurrentSymbol
	mov	bx,es:[bx]
	test	CompilerFlags.B0,cfDebugging
	jz	@@1
	test	bx,fnImmediate
	jnz	@@1
	mov	ax,133
	Chain	CompileError
@@1:	and	bx,not (fnNeed8087+fnImmediate)
	Invoke	GetToken
	mov	ax,cs:@@2[bx+2]
	jmp	cs:@@2[bx]
@@2	dw	_NewFunc,0
	dw	_Eof,_GetSEoln
	dw	_Eof,_GetSEof
	dw	_Eof,_GetTEoln
	dw	_Eof,_GetTEof
	dw	_FilePos,_GetFPos
	dw	_FilePos,_GetFSize
	dw	_UpCase,0
	dw	_Abs,0
	dw	_Sqr,0
	dw	_Succ,SuccTbl
	dw	_Succ,PredTbl
	dw	_Odd,0
	dw	_Ord,0
	dw	_Chr,0
	dw	_Ptr,0
	dw	_Ofs,1
	dw	_Ofs,2
	dw	_CSeg,CSegTbl
	dw	_CSeg,DSegTbl
	dw	_CSeg,SSegTbl
	dw	_CSeg,SPtrTbl
	dw	_SizeOf,0
	dw	_Sqrt,SqrtTb
	dw	_Sqrt,IntTb
	dw	_Sqrt,SinTb
	dw	_Sqrt,CosTb
	dw	_Sqrt,ArcTanT
	dw	_Sqrt,LnTb
	dw	_Sqrt,ExpTb
	dw	_Trunc,TruncTb
	dw	_Trunc,RoundTb
	dw	_MemAvail,MemAvTb
	dw	_MemAvail,MaxAvTb
	dw	_Length,0
	dw	_Pos,0
	dw	_Copy,0
	dw	_Concat,0
	dw	_IOResult,_GetIORes
	dw	_Sqrt,FracTb
	dw	_Random,0
	dw	_ParamStr,0
	dw	_ParamCount,_GetParCnt
	dw	_Lo,0
	dw	_Hi,0
	dw	_Swap,0
	dw	_Pi,0
	dw	_Ofs,0
	dw	_TypeOf,0
TruncTb	dw	_FTrunc+fnNeed8087,_RTrunc
RoundTb	dw	_FRound+fnNeed8087,_RRound
IntTb	dw	_FInt+fnNeed8087,_RInt
FracTb	dw	_FFrac+fnNeed8087,_RFrac
SqrtTb	dw	_FSqrt+fnNeed8087,_RSqrt
SinTb	dw	_FSin+fnNeed8087,_RSin
CosTb	dw	_FCos+fnNeed8087,_RCos
LnTb	dw	_FLn+fnNeed8087,_RLn
ExpTb	dw	_FExp+fnNeed8087,_RExp
ArcTanT	dw	_FArcTan+fnNeed8087,_RArcTan
CSegTbl	dw	0c88ch,rCS		; mov	ax,cs
DSegTbl	dw	0d88ch,rDS		; mov	ax,ds
SSegTbl	dw	0d08ch,rSS		; mov	ax,ss
SPtrTbl	dw	0e089h,rSP		; mov	ax,sp
MemAvTb	dw	_GetFreMem,MemAvailProc
MaxAvTb	dw	_GetFreMax,MaxAvailProc
StdFunction	endp

_Abs	proc	near
	Invoke	GetNumParam
	Invoke	GetVarValue
	les	bx,[di].exType
	cmp	es:[bx].tdType,ttInteger
	jne	@@4
	cmp	[di].exLocation,elImmediate
	je	@@2
	mov	al,emInteger
	mov	ah,[di].exModifier
	Invoke	IntExtension
	Invoke	ConvertOrdinal
	test	[di].exModifier,emXX
	jnz	@@1
	or	[di].exRegsUsed,erDX
	Invoke	UseExpr
	mov	al,lvAX
	Invoke	LoadValue
	mov	al,99h			; cwd
	Invoke	PutByte
	mov	ax,0d031h		; xor	ax,dx
	Invoke	PutWord
	mov	ax,0d029h		; sub	ax,dx
	Invoke	PutWord
	Chain	DoneExpr
@@1:	Invoke	UseExpr
	mov	al,lvAX
	Invoke	LoadValue
	mov	ax,_LongAbs
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exRegsUsed,erAll
	ret
@@2:	cmp	[di].exValue.W2,0
	jns	@@3
	xor	ax,ax
	xor	dx,dx
	sub	ax,[di].exValue.W0
	sbb	dx,[di].exValue.W2
	Chain	SetValue
@@3:	ret
@@4:	cmp	es:[bx].tdType,tt8087
	jne	@@7
	cmp	[di].exLocation,elImmediate
	je	@@6
@@5:	Invoke	ConvReal2Ext
	Invoke	PushExt
	Invoke	UseExpr
	Invoke	PutEmulInt
	mov	ax,0e135h		; fabs
	Invoke	PutWord
	Chain	DoneExpr
@@6:	and	[di].exValue.B9,7fh
	ret
@@7:	test	CompilerOptions,co8087
	jnz	@@5
	Invoke	UseExpr
	mov	al,lrR1
	Invoke	LoadReal
	mov	ax,0e680h		; and	dh,7fh
	Invoke	PutWord
	mov	al,7fh
	Invoke	PutByte
	Chain	DoneExpr
_Abs	endp

_Sqr	proc	near
	Invoke	GetNumParam
	cmp	es:[bx].tdType,ttInteger
	jne	@@2
	mov	al,emInteger
	mov	ah,[di].exModifier
	Invoke	IntExtension
	Invoke	ConvertOrdinal
	test	[di].exModifier,emXX
	jnz	@@1
	Invoke	UseExpr
	mov	al,lvAX
	Invoke	LoadValue
	mov	ax,0e8f7h		; mul	ax
	Invoke	PutWord
	Invoke	DoneExpr
	or	[di].exRegsUsed,erDX
	ret
@@1:	Invoke	UseExpr
	mov	al,lvAX
	Invoke	LoadValue
	mov	ax,_LongSqr
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exRegsUsed,erAll
	ret
@@2:	test	CompilerOptions,co8087
	jz	@@3
	Invoke	ConvReal2Ext
	Invoke	PushExt
	Invoke	UseExpr
	Invoke	PutEmulInt
	mov	ax,0c035h		; fld	st(0)
	Invoke	PutWord
	Invoke	PutEmulInt
	mov	ax,0c93ah		; fmul
	Invoke	PutWord
	Chain	DoneExpr
@@3:	Invoke	ConvExt2Real
	Invoke	UseExpr
	mov	al,lrR1
	Invoke	LoadReal
	mov	ax,_RSqr
	Invoke	PutSystemCall
	Chain	DoneExpr
_Sqr	endp

_Succ	proc	near
	push	ax
	Invoke	GetOrdParam
	Invoke	GetVarValue
	pop	si
	cmp	[di].exLocation,elImmediate
	je	@@3
	cmp	[di].exLocation,elAddress
	je	@@4
	Invoke	UseExpr
	mov	al,lvAX
	Invoke	LoadValue
	test	[di].exModifier,emXX
	jnz	@@2
	test	[di].exModifier,emX
	jnz	@@1
	mov	ax,cs:[si+1]
	Invoke	PutWord
	Chain	DoneExpr
@@1:	mov	al,cs:[si+3]
	Invoke	PutByte
	Chain	DoneExpr
@@2:	mov	ax,cs:[si+4]
	Invoke	PutWord
	mov	ax,cs:[si+6]
	Invoke	PutWord
	mov	ax,cs:[si+8]
	Invoke	PutWord
	Chain	DoneExpr
@@3:	mov	al,cs:[si]
	cbw
	cwd
	add	ax,[di].exValue.W0
	adc	dx,[di].exValue.W2
	Chain	SetValue
@@4:	mov	al,cs:[si]
	cbw
	add	[di].exValue.Offs,ax
	ret
SuccTbl	db	1
	inc	al
	inc	ax
	add	ax,1
	adc	dx,0
PredTbl	db	-1
	dec	al
	dec	ax
	sub	ax,1
	sbb	dx,0
_Succ	endp

_Odd	proc	near
	Invoke	GetIntParam
	Invoke	GetVarValue
	mov	[di].exModifier,emBoolean
	cmp	[di].exLocation,elImmediate
	je	@@1
	Invoke	UseExpr
	mov	al,lvAX
	Invoke	LoadValue
	mov	ax,0e8d0h		; shr	al,1
	Invoke	PutWord
	Invoke	DoneExpr
	mov	al,cdBelow
	Chain	_SetCondition
@@1:	and	[di].exValue.W0,1
	and	[di].exValue.W2,0
	Chain	CastBoolean
_Odd	endp

_Ord	proc	near
	Invoke	GetOrdParam
	Invoke	MarkReadOnly
	Chain	CastLongint
_Ord	endp

_Chr	proc	near
	Invoke	GetIntParam
	Invoke	MarkReadOnly
	mov	al,emByte
	Invoke	ConvertOrdinal
	mov	ax,SystemUnit
	mov	[di].exType.Offs,_Char
	mov	[di].exType.Segm,ax
	ret
_Chr	endp

_UpCase	proc	near
	Invoke	NeedOParen
	Invoke	GetExpr
	cmp	es:[bx].tdType,ttChar
	jne	@@1
	Invoke	NeedCParen
	Invoke	CastByte
	Invoke	PushValue
	Invoke	UseExpr
	mov	ax,_UpperCase
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emByte
	mov	[di].exRegsUsed,erAll
	mov	[di].exMisc,lvAX
	ret
@@1:	mov	ax,106
	Chain	CompileError
_UpCase	endp

_Lo	proc	near
	Invoke	GetIntParam
	Invoke	MarkReadOnly
	mov	al,emByte
	Chain	ConvertOrdinal
_Lo	endp

_Hi	proc	near
	Invoke	GetIntParam
	Invoke	MarkreadOnly
	Invoke	GetVarValue
	cmp	[di].exLocation,elImmediate
	je	@@3
	mov	al,emWord
	Invoke	ConvertOrdinal
	cmp	[di].exLocation,elMemory
	jne	@@1
	inc	[di].exValue.Offs
	jmp	short @@2
@@1:	Invoke	UseExpr
	mov	al,lvAX
	Invoke	LoadValue
	mov	ax,0e088h		; mov	al,ah
	Invoke	PutWord
	Invoke	DoneExpr
@@2:	mov	[di].exModifier,emByte
	ret
@@3:	mov	al,[di].exValue.B1
	xor	ah,ah
	xor	dx,dx
	Chain	SetValue
_Hi	endp

_Swap	proc	near
	Invoke	GetIntParam
	Invoke	GetVarValue
	cmp	[di].exLocation,elImmediate
	je	@@1
	mov	al,emWord
	Invoke	ConvertOrdinal
	Invoke	UseExpr
	mov	al,lvAX
	Invoke	LoadValue
	mov	ax,0c486h		; xchg	al,ah
	Invoke	PutWord
	Chain	DoneExpr
@@1:	mov	ax,[di].exValue.W0
	xchg	al,ah
	xor	dx,dx
	Chain	SetValue
_Swap	endp

	Loc	Temp,byte,<size TExpr>
_Ptr	proc	near
	Entry
	Invoke	NeedOParen
	push	di
	lea	di,Temp
	Invoke	GetIntExpr
	Invoke	GetVarValue
	Invoke	CastWord
	pop	di
	Invoke	NeedComma
	Invoke	GetIntExpr
	Invoke	GetVarValue
	Invoke	CastWord
	Invoke	NeedCParen
	lea	si,Temp
	cmp	[di].exLocation,elImmediate
	jne	@@1
	cmp	[si].exLocation,elImmediate
	jne	@@1
	mov	ax,[si].exValue.W0
	mov	[di].exValue.Segm,ax
	jmp	short @@2
@@1:	Invoke	MakePtr
	Invoke	DoneExpr
	mov	al,[si].exRegsUsed
	or	[di].exRegsUsed,al
@@2:	mov	[di].exModifier,emLongint
	Invoke	CastPointer
	Exit
_Ptr	endp

_Ofs	proc	near
	push	ax
	Invoke	NeedOParen
	Invoke	GetRef
	pop	cx
	push	cx
	Invoke	GetAddress
	Invoke	NeedCParen
	pop	cx
	cmp	cl,1
	jb	@@2
	je	@@1
	mov	ax,2
	Invoke	SwapSegOfs
@@1:	mov	al,emWord
	Invoke	ConvertOrdinal
	Chain	CastLongint
@@2:	Chain	CastPointer
_Ofs	endp

_CSeg	proc	near
	mov	si,ax
	test	CompilerFlags.B0,cfDebugging
	jnz	@@1
	mov	ax,cs:[si]
	Invoke	PutWord
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emWord
	mov	[di].exRegsUsed,erAX
	mov	[di].exMisc,lvAX
	Chain	CastLongint
@@1:	Invoke	CheckProgLoaded
	mov	[di].exCode,0
	mov	[di].exLocation,elImmediate
	mov	[di].exRegsUsed,0
	les	bx,CurRegs
	add	bx,cs:[si+2]
	mov	ax,es:[bx]
	xor	dx,dx
	Invoke	SetValue
	Chain	CastLongint
_CSeg	endp

_SizeOf	proc	near
	Invoke	NeedOParen
	Invoke	GetSymbol
	mov	al,CurrentToken
	cmp	al,t_Type
	je	@@2
	cmp	al,tString
	je	@@2
	cmp	al,tFile
	je	@@2
	Invoke	GetReference
	les	bx,[di].exType
	cmp	es:[bx].tdType,ttObject
	jne	@@3
	cmp	es:[bx].otVMTSize,0
	je	@@3
	mov	ax,es:[bx].otVMTOffset
	add	[di].exValue.Offs,ax
	test	CompilerFlags.B0,cfDebugging
	jnz	@@1
	Invoke	UseExpr
	mov	dx,388bh		; mov	di,...
	Invoke	AddReg
	mov	ax,058bh		; mov	di,[di]
	Invoke	PutWord
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emWord
	or	[di].exRegsUsed,erAX
	mov	[di].exMisc,lvAX
	jmp	short @@5
@@1:	Invoke	CheckProgLoaded
	les	bx,dword ptr [di].exValue
	mov	bx,es:[bx]
	mov	es,DataSegment.Segm
	mov	ax,es:[bx]
	jmp	short @@4
@@2:	push	di
	Invoke	GetTypeName
	mov	bx,di
	pop	di
@@3:	mov	ax,es:[bx].tdSizeOf
@@4:	xor	dx,dx
	mov	[di].exCode,dx
	mov	[di].exLocation,elImmediate
	mov	[di].exRegsUsed,dl
	Invoke	SetValue
@@5:	Invoke	NeedCParen
	Chain	CastLongint
_SizeOf	endp

_TypeOf	proc	near
	Invoke	NeedOParen
	Invoke	GetSymbol
	cmp	CurrentToken,t_Type
	je	@@2
	Invoke	GetReference
	les	bx,[di].exType
	call	Check
	mov	ax,es:[bx].otVMTOffset
	add	[di].exOffset,ax
	test	CompilerFlags.B0,cfDebugging
	jnz	@@1
	Invoke	UseExpr
	mov	[di].exModifier,emWord
	mov	al,lvAX
	Invoke	LoadValue
	mov	ax,0da8ch		; mov	dx,ds
	Invoke	PutWord
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emLongint
	or	[di].exRegsUsed,erAX+erDX
	mov	[di].exMisc,lvAX
	jmp	short @@5
@@1:	Invoke	CheckProgLoaded
	les	bx,dword ptr [di].exValue
	mov	ax,es:[bx]
	jmp	short @@4
@@2:	push	di
	Invoke	GetTypeName
	mov	bx,di
	pop	di
	call	Check
	test	CompilerFlags.B0,cfDebugging
	jnz	@@3
	xor	ax,ax
	mov	cx,es:[bx].otVMTAddr
	mov	[di].exCode,ax
	mov	[di].exRegsUsed,al
	mov	[di].exLocation,elAddress
	mov	[di].exModifier,emLongint
	mov	[di].exMisc,efDS+efConst
	mov	[di].exOffset,ax
	mov	[di].exMap,cx
	mov	[di].exSegment,es
	jmp	short @@5
@@3:	Invoke	CheckProgLoaded
	mov	bx,es:[bx].otVMTAddr
	add	bx,es:uhConstMap
	mov	ax,es:[bx]
	cmp	ax,-1
	je	@@6
@@4:	mov	dx,DataSegment.Segm
	mov	[di].exCode,0
	mov	[di].exLocation,elImmediate
	mov	[di].exRegsUsed,0
	Invoke	SetValue
@@5:	Invoke	NeedCParen
	Chain	CastPointer

Check	proc	near
	cmp	es:[bx].tdType,ttObject
	jne	@@1
	cmp	es:[bx].otVMTSize,0
	je	@@1
	ret
@@1:	mov	ax,147
	Chain	CompileError
Check	endp

@@6:	mov	ax,139
	Chain	CompileError
_TypeOf	endp

_Sqrt	proc	near
	push	ax
	Invoke	GetNumParam
	pop	si
ZZT	label	near
	test	CompilerOptions,co8087
	jz	@@1
	push	cs:[si]
	Invoke	ConvInt2Ext
	Invoke	ConvReal2Ext
	Invoke	PushExt
	Invoke	UseExpr
	jmp	short @@2
@@1:	push	cs:[si+2]
	Invoke	ConvInt2Real
	Invoke	ConvExt2Real
	Invoke	UseExpr
	mov	al,lrR1
	Invoke	LoadReal
@@2:	pop	ax
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exRegsUsed,erAll
	ret
_Sqrt	endp

_Trunc	proc	near
	push	ax
	Invoke	GetNumParam
	Invoke	GetVarValue
	pop	si
	cmp	[di].exLocation,elImmediate
	jne	@@2
	Invoke	ConvInt2Ext
	xor	ax,ax
	cmp	si,offset TruncTb
	je	@@1
	inc	ax
@@1:	lea	bx,[di].exValue
	Invoke	TruncExtended
	mov	ax,[bx].W0
	mov	dx,[bx].W2
	Invoke	SetValue
	Chain	CastLongint
@@2:	call	ZZT
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emLongint
	mov	[di].exMisc,lvAX
	Chain	CastLongint
_Trunc	endp

_Pi	proc	near
	mov	[di].exCode,0
	mov	[di].exLocation,elImmediate
	mov	[di].exModifier,emExtended
	mov	[di].exRegsUsed,0
	mov	[di].exValue.W0,0c235h
	mov	[di].exValue.W2,2168h
	mov	[di].exValue.W4,0daa2h
	mov	[di].exValue.W6,0c90fh
	mov	[di].exValue.W8,4000h
	Chain	CastExtended
_Pi	endp

_Random	proc	near
	Invoke	CheckOParen
	jnz	@@1
	Invoke	GetIntExpr
	Invoke	NeedCParen
	Invoke	CastWord
	Invoke	PushValue
	Invoke	UseExpr
	mov	ax,_RandInt
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emWord
	mov	[di].exRegsUsed,erAll
	mov	[di].exMisc,lvAX
	Chain	CastLongint
@@1:	test	CompilerOptions,co8087
	jnz	@@2
	mov	ax,_RandReal
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emReal
	mov	[di].exRegsUsed,erAll
	Chain	CastReal
@@2:	mov	ax,_RandFloat+fnNeed8087
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exLocation,elStack
	mov	[di].exModifier,emExtended
	mov	[di].exRegsUsed,erAll
	Chain	CastExtended
_Random	endp

_NewFunc	proc	near
	Invoke	NeedOParen
	push	di
	Invoke	GetTypeName
	mov	bx,di
	pop	di
	cmp	es:[bx].tdType,ttPointer
	jne	@@1
	Invoke	_New
	Chain	NeedCParen
@@1:	mov	ax,33
	Chain	CompileError
_NewFunc	endp

_MemAvail	proc	near
	xchg	ax,si
	test	CompilerFlags.B0,cfDebugging
	jnz	@@1
	mov	ax,cs:[si]
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emLongint
	mov	[di].exRegsUsed,erAll
	mov	[di].exMisc,lvAX
	Chain	CastLongint
@@1:	Invoke	CheckProgLoaded
	call	word ptr cs:[si+2]
	mov	[di].exCode,0
	mov	[di].exLocation,elImmediate
	mov	[di].exRegsUsed,0
	Invoke	SetValue
	Chain	CastLongint

MemAvailProc	proc	near
	lea	bx,@@4
	jmp	short Avail
@@1:	add	dx,1000h
	jmp	short @@3
@@2:	add	ax,[si+4]
	jc	@@1
@@3:	add	dx,[si+6]
	lds	si,[si]
@@4:	mov	bx,ds
	cmp	bx,cx
	jne	@@2
	ret
MemAvailProc	endp

MaxAvailProc	proc	near
	lea	bx,@@4
	jmp	short Avail
@@1:	cmp	dx,[si+6]
	ja	@@3
	jb	@@2
	cmp	ax,[si+4]
	jae	@@3
@@2:	mov	ax,[si+4]
	mov	dx,[si+6]
@@3:	lds	si,[si]
@@4:	mov	bx,ds
	cmp	bx,cx
	jne	@@1
	ret
MaxAvailProc	endp

Avail	proc	near
	push	ds
	lds	si,DataSegment
	mov	ax,[si]._HeapEnd.Offs
	mov	dx,[si]._HeapEnd.Segm
	sub	ax,[si]._HeapPtr.Offs
	sbb	dx,[si]._HeapPtr.Segm
	and	ax,0fh
	mov	cx,[si]._HeapPtr.Segm
	lds	si,[si]._FreeList
	call	bx
	mov	cl,4
	rol	dx,cl
	mov	cx,dx
	and	cl,0f0h
	and	dx,0fh
	add	ax,cx
	adc	dx,0
	pop	ds
	ret
Avail	endp

_MemAvail	endp

_Length	proc	near
	Invoke	NeedOParen
	Invoke	GetStringExpr
	Invoke	NeedCParen
	Invoke	MarkReadOnly
	Chain	StringLength
_Length	endp

_Pos	proc	near
	Loc	S,byte,<size TExpr>
	Entry
	Invoke	NeedOParen
	Invoke	PushStringExpr
	push	di
	Invoke	NeedComma
	lea	di,S
	Invoke	PushStringExpr
	Invoke	NeedCParen
	pop	di
	Invoke	UseExpr
	mov	ax,S.exCode
	Invoke	UseGoal
	mov	ax,_SPos
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emInteger
	mov	[di].exRegsUsed,erAll
	mov	[di].exMisc,lvAX
	Invoke	CastLongint
	Exit
_Pos	endp

_Copy	proc	near
	Loc	Index,byte,<size TExpr>
	Loc	Count,byte,<size TExpr>
	Entry
	Invoke	NeedOParen
	Invoke	PushStringExpr
	push	di
	Invoke	NeedComma
	lea	di,Index
	Invoke	GetIntExpr
	Invoke	CastInt
	Invoke	PushValue
	Invoke	NeedComma
	lea	di,Count
	Invoke	GetIntExpr
	Invoke	CastInt
	Invoke	PushValue
	Invoke	NeedCParen
	pop	di
	mov	ax,256
	Invoke	CreateLocalVar
	Invoke	UseExpr
	mov	ax,Index.exCode
	Invoke	UseGoal
	mov	ax,Count.exCode
	Invoke	UseGoal
	mov	ax,_SCopy
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exRegsUsed,erAll
	Exit
_Copy	endp

_Concat	proc	near
	Loc	S,byte,<size TExpr>
	Entry
	Invoke	NeedOParen
	Invoke	GetStringExpr
	Invoke	LoadString
@@1:	Invoke	CheckComma
	jnz	@@2
	push	di
	lea	di,S
	Invoke	PushStringExpr
	pop	di
	Invoke	UseExpr
	mov	ax,S.exCode
	Invoke	UseGoal
	mov	ax,_SConcat
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exRegsUsed,erAll
	jmp	@@1
@@2:	Invoke	NeedCParen
	Exit
_Concat	endp

_ParamStr	proc	near
	Invoke	GetIntParam
	Invoke	CastInt
	Invoke	PushValue
	mov	ax,256
	Invoke	CreateLocalVar
	Invoke	UseExpr
	mov	ax,_GetParStr
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exRegsUsed,erAll
	Chain	CastString
_ParamStr	endp

_ParamCount	proc	near
	Invoke	PutSystemCall
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emInteger
	mov	[di].exRegsUsed,erAll
	mov	[di].exMisc,lvAX
	Chain	CastLongint
_ParamCount	endp

_IOResult	proc	near
	test	CompilerFlags.B0,cfDebugging
	jnz	@@1
	call	_ParamCount
	mov	[di].exRegsUsed,erAX
	ret
@@1:	Invoke	CheckProgLoaded
	les	bx,DataSegment
	mov	ax,es:[bx]._InOutRes
	cwd
	mov	[di].exCode,0
	mov	[di].exLocation,elImmediate
	mov	[di].exRegsUsed,0
	Invoke	SetValue
	Chain	CastLongint
_IOResult	endp

_Eof	proc	near
	push	ax
	Invoke	CheckOParen
	jz	@@1
	xor	ax,ax
	mov	dx,_Input
	Invoke	DefaultFile
	jmp	short @@3
@@1:	Invoke	PushFileRef
	cmp	es:[bx].tdType,ttText
	je	@@2
	pop	ax
	cmp	ax,_GetTEof
	jne	@@4
	mov	ax,_GetFEof
	push	ax
@@2:	Invoke	NeedCParen
	Invoke	UseExpr
@@3:	pop	ax
	Invoke	PutSystemCall
	Invoke	CheckIOResult
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emBoolean
	mov	[di].exRegsUsed,erAll
	mov	[di].exMisc,lvAX
	Chain	CastBoolean
@@4:	mov	ax,63
	Chain	CompileError
_Eof	endp

_FilePos	proc	near
	push	ax
	Invoke	NeedOParen
	Invoke	PushFileRef
	cmp	es:[bx].tdType,ttFile
	jne	@@1
	Invoke	NeedCParen
	Invoke	UseExpr
	pop	ax
	Invoke	PutSystemCall
	Invoke	CheckIOResult
	Invoke	DoneExpr
	mov	[di].exLocation,elRegister
	mov	[di].exModifier,emLongint
	mov	[di].exRegsUsed,erAll
	mov	[di].exMisc,lvAX
	Chain	CastLongint
@@1:	mov	ax,63
	Chain	CompileError
_FilePos	endp

	end
