include	clib.inc
include	conio.inc

PPROC	thelpinit, hproc:FPTR
	mov	ax,word ptr hproc
	mov	word ptr thelp,ax
	mov	word ptr thelp_stack,ax
  ifdef LPROG
	mov	dx,word ptr hproc+2
	mov	word ptr thelp+2,dx
	mov	word ptr thelp_stack+2,dx
  endif
	ret
PEND	thelpinit

PPROC	thelp_set, hproc:FPTR
	inc	stack_index
	mov	bx,stack_index
	add	bx,bx
	mov	ax,word ptr hproc
	mov	word ptr thelp,ax
  ifdef LPROG
	mov	dx,word ptr hproc+2
	mov	word ptr thelp+2,dx
	add	bx,bx
	mov	word ptr thelp_stack[bx+2],dx
  endif
	mov	word ptr thelp_stack[bx],ax
	ret
PEND	thelp_set

DPROC	thelp_pop
	push	bx
	dec	stack_index
	mov	bx,stack_index
	add	bx,bx
  ifdef LPROG
	add	bx,bx
	push	word ptr thelp_stack[bx+2]
	pop	word ptr thelp+2
  endif
	push	word ptr thelp_stack[bx]
	pop	word ptr thelp
	pop	bx
	ret
PEND	thelp_pop

_DATA	SEGMENT

thelp		PF	0
thelp_stack	PF  10	dup(0)
stack_index	dw	0

_DATA	ENDS

	END
