	model	large extend_text,pascal
	include	extend.inc

	extrn	ExtMul:far,ExtDiv:far,Ulong2Ext:far

	.data
Tab1	dd	1,10,100,1000,10000,100000,1000000,10000000
Tab2	dt	1e8,1e16,1e32,1e64,1e128,1e256,1e512,1e1024,1e2048,1e4096

	.code	Extend_Text

	Argm	N,word,1
	Argm	A,dword,1
	Loc	Temp,word,5
	Entry	ExtPow10
	push	si di
	mov	si,N
	or	si,si
	jz	@@7
	jns	@@1
	neg	si
@@1:	cmp	si,4999
	jbe	@@2
	mov	si,4999
@@2:	mov	bx,7
	and	bx,si
	shl	bx,1
	shl	bx,1
	add	bx,offset Tab1
	push	dword ptr [bx]
	lea	ax,Temp
	push	ss ax
	call	Ulong2Ext
	mov	cl,3
	shr	si,cl
	lea	di,Tab2
@@3:	or	si,si
	jz	@@5
	shr	si,1
	jnc	@@4
	lea	ax,Temp
	push	ss ax ds di
	call	ExtMul
@@4:	add	di,10
	jmp	@@3
@@5:	les	ax,A
	push	es ax
	lea	ax,Temp
	push	ss ax
	cmp	N,0
	jns	@@6
	call	ExtDiv
	jmp	short @@7
@@6:	call	ExtMul
@@7:	pop	di si
	Exit

	end
