	ORG 0100H ;STANDARD CP/M ORIGIN
	LXI SP,STACK
I10:
	LHLD ZA$
	MVI A,32!MOV M,A
	LXI H, 1 !SHLD ZA$+2
	LXI H,ZA$!SHLD ZB
	MOV E,M!INX H!MOV D,M!XCHG!SHLD ZC
	JMP I10B
I10A: DB 53,48,32,73,84,69,82,65,84,73,79,78,83
I10B:LXI H,I10A
	LXI D,13
	LXI B,2
	CALL PSTR
	CALL PLNE
	LXI H,1
	SHLD ZM
FOR1: MVI A,50! CMP L! JC NXT1
	LXI H,0
	SHLD ZCOUNT
	lxi h,STACK+257! lxi d,STACK+257
	mvi a,1! lxi b,8191! stax d! inx d! dcx b
db	0edH, 0b0h
I20:
	lxi h,STACK+256
	SHLD ZD
I80:
	LXI H,0
	SHLD ZI
FOR3: LXI D, -8191! dad d! jc NXT3
I90:
	LHLD ZD!INX H!SHLD ZD
	MOV A,M
	CPI 0! JZ I170
I100:
	LHLD ZI
	DAD H
	inx h! inx h! inx h
	SHLD ZPRIME
	XCHG
	LHLD ZI
	DAD D
	SHLD ZK
I120:
	lxi d,-8191! dad d! jc I160
I130:
	lxi d,STACK+257
	LHLD ZK! mov b,h! mov c,l
	DAD D
	xra A! MOV M,A
	LHLD ZPRIME
	DAD B
	SHLD ZK
	JMP I120
I160:
	LHLD ZCOUNT!INX H!SHLD ZCOUNT
I170:
	LHLD ZI!INX H!SHLD ZI!JMP FOR3
NXT3:
I180:
	LHLD ZM!INX H!SHLD ZM!JMP FOR1
NXT1:
I190:
	LHLD ZCOUNT
	LXI B,2
	CALL PNUM
	JMP I190B
I190A: DB 32,80,82,73,77,69,83,46
I190B:LXI H,I190A
	LXI D,8
	LXI B,2
	CALL PSTR
	CALL PLNE
I200:
	JMP 000H
	CALL 0000H
PSTR:	MOV	A,D! ORA A! JNZ PLOOP! MOV A,E! ORA A! RZ
PLOOP:	PUSH	D! PUSH B! MOV E,M! PUSH H! PUSH PSW
	CALL	0005H
	POP	PSW! POP H! POP B! POP D! INX H! DCX D! MOV A,E! ORA A
	JNZ	PLOOP
	MOV	A,D! ORA A! JNZ PLOOP
	RET
PLNE:	PUSH	B! MVI E,13
	CALL	0005! POP B! PUSH B! MVI E,10
	CALL	0005! POP B! RET
PNUM:	LXI	D,SAREA! PUSH B! MOV A,H! ANI 080H! JZ PNUM2
	MOV	A,H! CMA! MOV H,A! MOV A,L! CMA! MOV L,A! INX H
	MVI	A,'-'! STAX D! JMP PNUM3
PNUM2:	MVI	A,'+'! STAX D
PNUM3:	INX	D
	LXI	B,-10000! CALL DECDIG
	LXI	B,-1000! CALL DECDIG
	LXI	B,-100! CALL DECDIG
	LXI	B,-10! CALL DECDIG
	MOV	A,L! ORI '0'! STAX D
	LXI	D,0006H! LXI H,SAREA
	POP	B! JMP PSTR
DECDIG:	MVI	A,'0'-1
DECLP:	INR	A! DAD B! JC DECLP
	STAX	D! INX D! MOV A,B! CMA
	MOV	B,A! MOV A,C! CMA
	MOV	C,A! INX B! DAD B! RET
ARITH2:	MOV	A,H! CMA! MOV H,A
	MOV	A,L! CMA! MOV L,A! INX H! DAD D! RET
ZA$: DW STACK+257,0
ZB: DW 0
ZC: DW 0
ZM: DW 0
ZCOUNT: DW 0
ZD: DW 0
ZI: DW 0
ZPRIME: DW 0
ZK: DW 0
	DS 8
STACK:
SAREA: DW 0
	END
