
ORG	800H



;====================
;  ARITMETIKA INTEL
;====================



;1975
;24-BIT FLOATING POINT ROUTINES FOR I 8080

;NUMBER
;  N=0  OR
;  N=SIGN*(1+FRACTION)*2**EXPONENT
;IS REPRESENTING
;  M.F.BYTE L.F.BYTE E.S.BYTE
;  -------- -------- --------
;  FFFFFFFF FFFFFFFF SEEEEEEE N<>0, S=0/1..+/-
;                             EXP=EXPONENT+64
;  ........ ........ 00000000 N=0 (+0)
;  ........ ........ 10000000 ILLEGAL (-0)
;PROPER BINARY CODE IS USED.

;RANGE: 10**(-19) < ABS(N) < 10**19   APPROX
;ACCURACY: BETTER THAN 1 IN 2**17,
;          I.E. 4 DECIMAL DIGITS
;IN THE COMPUTATIONS IS USUALLY USED 24 BITS FRACTION.
;  (EXTENSION FRAC. BYTE)

;OPERANDS
;  1-ST..LEFT..X: CDE, C=ESB, D=MFB, E=LFB
;  2-ND..RIGHT.Y: BHL, B=ESB, H=MFB, L=LFB
;RESULT OF OPERATION
;  IF CY=0 ..X: CDE
;            B=PRECISION LOSS (THE NUMBER OF 
;                 NORMALIZATION LEFT SHIFTS),-1..17
;            A,FLAGS,H,L..DESTROYED
;  IF CY=1 ..ERROR:A=0  DOMAIN ER.(AS DIVIDE BY 0)
;                ( A=1  -0 IN X-OPERAND )
;                ( A=2  -0 IN Y-OPERAND )
;                  A=3  UNDERFLOW
;                  A=4  OVERFLOW
;                  A=5  INTEGER OVERFLOW
;                       (IN CONVERSION TO INT.)
;           IF NO OPERAND IS -0 RESULT CAN'T BE -0.



;A & FLAGS ARE IRRELEVANT AT C_A_L_L TIME.
;EXCEPTIONS: CONVERSOIN FROM/TO INTEGER,
;            SCALING, COMPARISON.


; M_E_N_U  C_A_R_D



; FNAB	X:=ABS(X)

; FNNE	X:= -X
; FNSX	X:=Y-X
; FNSU	X:=X-Y

; FNXC	X <--> Y ,NO ERRORS, FLAGS:UNCHANGED

; FNAD	X:=X+Y

;CONVERT TO FLOATING POINT
;(NO ERRORS, B:NO ACCURACY LOSS)

; FN7C  X:=FLOAT(A), <A> V DOPLNKOVEM KODU
; FNCX	X:=FLOAT(HL), <HL> V DOPL.KODU
; FNCF	X:=FLOAT(DE), <DE> V DOPL.KODU

; FN8C	X:=FLOAT(A), <A> V PRIMEM KODU
; FNCY	X:=FLOAT(HL), <HL> V PRIMEM KODU
; FNCP	X:=FLOAT(DE), <DE> V PRIMEM KODU
; FNCQ	X:=FLOAT(ADE), <ADE> V PRIMEM KODU

;CONVERT TO INTEGER: 1)ROUNDING
;                    2)CONVERT TO 2'S COMPL.
;                       (DOPLNKOVY KOD)
; FNIX	ADE:=FIX(Y)
; FNC1	ADE:=FIX(X)
; FNIY	(H)DE:=FIX(Y) ..( Y<0 ==> H:=0 )
; FNCS	(H)DE:=FIX(X) ..( X<0 ==>H:=0 )


; FNSC	X:=X*SCALE(Y)
;   ..SCALE(@)...FRACTION(@):=0, UVAZUJE JEN MSB
; FN2P	X:=X*X
; FNMU	X:=X*Y

; FNIN	X:=1/X
; FNDX	X:=Y/X
; FNDI	X:=X/Y

; FNCM	COMPARE(X,Y): X>Y ==> S:=0, Z:=0
;                     X=Y ==> S:=0, Z:=1
;                     X<Y ==> S:=1, Z:=0
;       (X,Y: UNCHANGED)
; FNGN	X:=SIGN(X), X>0 ==> X:=+1
;                   X=0 ==> X:= 0
;                   X<0 ==> X:=-1
; FNGM	X:=SGN(X), X>=0 ==> X:=+1
;                  X<0  ==> X:=-1
;...FNCM,FNGN & FNGM USE NO OTHER ROUTINES,
;   THEY HAVE NO ERRORS (CY:=0)

; FNDP	X:=10**B, <B> V DOPLNKOVEM KODU
; FNDS	X:=SCALE(X)*10**B, <B> V DOPLNKOVEM KODU
;                          SCALE(@)..VIZ FNSC

; FNLN	X:=LN(X)
; FNEN	X:=EXP(X), X<43
; FN2N	X:=2**X, X<63

;GONIOMETRICKE FUNKCE: ARGUMENT X JE V GRAD/100  (T=4)
;                      ABS(X) >= 4096 ==> DOMAIN ERROR
; FNTS	X:=SIN(X*PI/2)
; FNTC	X:=COS(X*PI/2)
; FNTG	X:= TG(X*PI/2)

;INVERZNI GONIOMETRICKE FCE: VYSLEDEK V RADIANECH
;                            NO ERRORS
; FACN	X:=ARCCOS(X)
; FASN	X:=ARCSIN(X)
; FATN  X:=ARCTG(X)


; FNRP  RETANGULAR(X,Y) TO POLAR (X:=R, Y:=THETA)
;        -PI < THETA <= PI, ERRORS: UNDER/OVERFLOW

; FNPR  POLAR (X=R, Y=THETA IN RAD) TO RETANGULAR(X,Y)
;               ABS(THETA) >= 2048*PI ==> DOMAIN ERROR

; FNNO  X:=SQRT(X*X+Y*Y)
; FNRT  X:=SQRT(X), X<0 ==> DOMAIN ERROR
; FNPO  X:=X**Y, X<=0 ==> DOMAIN ERROR


; FNFD  X:=INPUT(L)  
;        <HL>=ADR OF READ-CHAR-ROUTINE
;             (WHICH LEAVE CHARACTER IN A,
;             MAY CHANGE THE OTHER REGISTERS)
;       ERROR (CY=1): NUBER IS TOO LARGE OR IS NOT
;         AT FORMAT:  +-NNNNNN.NNNNNNE+-NN.
;         EVERY CHARACTER MAY BE DELETED,
;         THE SUM OF CIFFERS MUST NOT EXCEED 6.
;       NUMBER MAY BE ENDED WITH "," AT ANY POSITION.
  

; FNDC  OUTPUT(X)
;        <HL>=TTY-ADR (CHARACTER IN C)
;        FORMAT: +-N.NNNNNE+-NN
;______________________________
FNAB:
L800:	MOV	A,C
	ANA	A
	JP	L839
;______________________________
FNNE:
L805:	MVI	B,00
;______________________________
FNSX:
L807:	CALL	L814
;______________________________
FNSU:
L80A:	MOV	A,B
	ANA	A
	RZ
	XRI	80H
	MOV	B,A
	SUB	A
	JMP	L81C
;______________________________
FNXC:
L814:	MOV	A,B
	MOV	B,C
	MOV	C,A
	XCHG
	RET
;______________________________
FNAD:
L819:	SUB	A
	CMP	B
	RZ
L81C:	CMP	C
	JZ	L814
	MOV	A,B
	XRA	C
	ANI	80H
	ADD	C
L825:	SUB	B
	JZ	L8FF
	CM	L814
	MOV	A,C
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	L8D8
	STC
	RET
L8D7:	MOV	H,C
L8D8:	MVI	A,0FFH
	RAR
	MOV	C,A
	MVI	A,04H
	RET
L8DF:	ADI	0EEH
	JNC	L8E9
	MOV	A,B
	SUB	L
	MOV	L,H
	MOV	H,C
	MOV	C,B
L8E9:	MOV	A,B
	SBB	L
	MOV	L,A
	MOV	A,E
	SBB	H
	MOV	E,A
	MOV	A,D
	SBB	C
	MOV	D,A
	MOV	H,L
	JMP	L88D
L8F6:	DCX	H
	DCX	D
L8F8:	POP	B
	XCHG
	MOV	B,C
	MOV	A,C
	XRI	80H
	MOV	C,A
L8FF:	MOV	A,C
	XRA	B
	RAL
	MOV	B,C
	PUSH	B
	MOV	B,A
	JC	L90E
	DAD	D
	XCHG
	INR	A
	JMP	L878
L90E:	MOV	A,E
	SUB	L
	MOV	C,A
	MOV	A,D
	SBB	H
	JC	L8F8
	MOV	E,C
	MOV	H,B
	JMP	L892
;______________________________
FN7C:
L91B:	MOV	L,A
	RAL
	SBB	A
	MOV	H,A
;_______________________________
FNCX:
	XCHG
;______________________________
FNCF:
L920:	MOV	A,D
	RAL
L922:	LXI	H,0
	MVI	C,50H
	MOV	B,C
	PUSH	B
	MOV	B,H
	JC	L8F6
	JMP	L890
;______________________________
FN8C:
L930:	MOV	L,A
	MVI	H,00
;______________________________
FNCY:
	XCHG
;_______________________________
FNCP:
L934:	SUB	A
	JMP	L922
;______________________________
FNCQ:
L938:	MOV	H,E
	MOV	E,D
	MOV	D,A
	MVI	C,58H
	MOV	B,C
	PUSH	B
	MVI	B,00
	JMP	L890
;______________________________
FNIX:
	CALL	L814
;______________________________
FNC1:
L947:	MOV	A,C
	ADD	A
	ADI	52H
	JNC	L959
	MVI	B,01H
	ORA	D
	ORA	E
	SUB	B
	MOV	A,B
	RAR
	ANA	C
	CMP	B
	DCR	B
	RET
L959:	CMA
	RAR
	SUI	06
	XCHG
	LXI	D,000
	JC	L96F
	CPI	11H
	JC	L96F
	MOV	A,D
	MOV	B,D
	RNZ
	MOV	H,D
	MVI	A,10H
L96F:	MOV	E,C
	MOV	B,D
	MOV	D,A
	CALL	L83E
	MOV	A,D
	MOV	D,C
	DCR	A
	JM	L98E
	CPI	08
	MOV	A,L
	MOV	L,H
	MOV	H,D
	JM	L986
	MOV	A,L
	MOV	L,H
	MOV	H,B
L986:	RAL
	MOV	A,B
	RAL
	MOV	C,A
	DAD	B
	MOV	A,B
	RAL
	MOV	D,A
L98E:	XCHG
	MOV	A,H
	INR	L
	DCR	L
	RP
	MOV	A,B
	SUB	E
	MOV	E,A
	MOV	A,B
	SBB	D
	MOV	D,A
	MOV	A,B
	SBB	H
	ANA	A
	RET
;______________________________
FNIY:
	CALL	L814
;______________________________
FNCS:
L9A0:	CALL	L947
	RC
	MOV	A,D
	RAL
	MOV	A,H
	ADC	B
	ANA	A
	RZ
	SUB	A
	SUI	0FBH
	RET
;______________________________
FNSC:
	LXI	H,000
		JMP	L9B7
;______________________________
FN2P:
L9B4:	MOV	B,C
	MOV	H,D
L9B6:	MOV	L,E
;;______________________________
FNMU:
L9B7:	MOV	A,B
	ADI	0FFH
	SBB A
	ANA C
	JZ L83A
	PUSH	H
	ADD	B
	SUI	40H
	MOV	L,A
	MOV	A,C
	ANI	80H
	XRA	B
	MOV	H,A
	XTHL
	MVI	B,00
	MOV	A,H
	ORA	L
	JZ	L878
	PUSH	H
	MOV	C,H
	MOV	A,L
	MOV	H,B
	MOV	L,B
	CMP	B
	CNZ	L9F0
	MOV	L,A
	MOV	A,C
	MOV	C,H
	MOV	H,B
	CALL	L9F0
	DAD	B
	ADC	B
	MOV	C,L
	MOV	L,H
	MOV	H,A
	DAD	D
	MOV	A,B
	ADC	B
	POP	D
	DAD	D
	XCHG
	MOV	H,C
	JMP	L878
L9F0:	CALL	L9F3
L9F3:	DAD	H
	ADC	A
	JNC	L9FA
	DAD	D
	ADC	B
L9FA:	DAD	H
	ADC	A
	JNC	LA01
	DAD	D
	ADC	B
LA01:	DAD	H
	ADC	A
	JNC	LA08
	DAD	D
	ADC	B
LA08:	DAD	H
	ADC	A
	RNC
	DAD	D
	ADC	B
	RET
;______________________________
FNIN:
LA0E:	LXI	H,0
	MVI	B,40H
;_______________________________
FNDX:
LA13:	CALL	L814
;______________________________
FNDI:
LA16:	SUB	A
	CMP	B
	JZ	L8D0
	CMP	C
	JZ	L83A
	PUSH	H
	MOV	A,C
	SUB	B
	ADI	40H
	MOV	L,A
	MOV	A,C
	ORI	7FH
	XRA	B
	MOV	H,A
	XTHL
	XCHG
	SUB	A
	SUB	E
	MOV	C,A
	MVI	A,00
	SBB	D
	MOV	B,A
	JNC	L8B7
	MVI	A,01H
	CALL	LA5F
	PUSH	PSW
	MVI	A,01H
	CALL	LA58
	PUSH	PSW
	MVI	A,20H
	CALL	LA52
	RRC
	RRC
	RRC
	POP	H
	MOV	L,A
	POP	PSW
	MVI	B,01H
	JMP	L8A5
LA52:	JC	LA64
	JMP	LA7A
LA58:	JNC	LA71
LA5B:	DAD	H
	JNC	LA63
LA5F:	DAD	B
	JNC	LA79
LA63:	RAL
LA64:	DAD	H
	JNC	LA6C
	DAD	B
	JNC	LA82
LA6C:	RAL
	JNC	LA5B
	RET
LA71:	DAD	H
	JC	LA79
	DAD	D
	JC	LA63
LA79:	RAL
LA7A:	DAD	H
	JC	LA82
	DAD	D
	JC	LA6C
LA82:	RAL
	JNC	LA71
	CMC
	RET
;______________________________
FNCM:
LA88:	MOV	A,C
	XRA	B
	MOV	A,C
	JM	LA9E
	SUB	B
	JNZ	LA9D
	ADD	C
	RZ
	MOV	A,D
	SUB	H
	JNZ	LA9C
	MOV	A,E
	SUB	L
	RZ
LA9C:	RAR
LA9D:	XRA	C
LA9E:	ORI	01
	RET
;______________________________
FNGN:
	SUB	A
	MOV	B,A
	ADD	C
	RZ
LAA5:	MOV	D,B
	MOV	E,B
	ANI	80H
	ADI	40H
	MOV	C,A
	RET
;______________________________
FNGM:
	SUB	A
	MOV	B,A
	ADD	C
	JMP	LAA5
;______________________________
FNDP:
LAB3:	MVI	C,40H
	LXI	D,000
;______________________________
FNDS:
LAB8:	MOV	A,B
	ANA	A
	LXI	H,L9B7
	JP	LAC5
	LXI	H,LA16
	CMA
	INR	A
LAC5:	JMP	LAD2
LAC8:	JNC	LAD0
	INX	SP
	INX	SP
	INX	SP
	INX	SP
	RET
LAD0:	POP	H
	POP	PSW
LAD2:	MOV	B,A
	ANA	A
	RZ
	CPI	08
	JM	LADC
	MVI	B,07H
LADC:	SUB	B
	PUSH	PSW
	PUSH	H
	PUSH	H
	LXI	H,LAC8
	XTHL
	PUSH	H
	MOV	A,C
	MOV	C,B
	MVI	B,00
	LXI	H,LAF9
	DAD	B
	DAD	B
	DAD	B
	MOV	C,A
	MOV	B,M
	DCX	H
	MOV	A,M
	DCX	H
	MOV	L,M
	MOV	H,A
	RET
	DB	0
	DB	0
LAF9:	DB	40H
	DB	0
	DB	40H
	DB	43H
	DB	0
	DB	90H
	DB	46H
	DB	0
	DB	0F4H
	DB	49H
	DB	80H
	DB	38H
	DB	4DH
	DB	0A0H
	DB	86H
	DB	50H
	DB	48H
	DB	0E8H
	DB	53H
	DB	2DH
	DB	31H
	DB	57H

;-------------------------- LN
LB0F:	MVI	B,0C0H
	LXI	H,0
	CALL	L819
	MOV	B,C
	PUSH	B
	PUSH	D
	MVI	B,41H
	LXI	H,0000
	CALL	L819
	POP	H
	POP	PSW
	MOV	B,A
	CALL	LA13
	MOV	B,C
	PUSH	B
	PUSH	D
	CALL	L9B4
	MOV	B,C
	PUSH	B
	PUSH	D
	MVI	B,3DH
	LXI	H,0ABCBH
	CALL	L9B7
	MVI	B,3EH
	LXI	H,5532H
	CALL	L819
	POP	H
	POP	PSW
	MOV	B,A
	CALL	L9B7
	MVI	B,40H
	LXI	H,0000
	CALL	L819
	INR	C
	POP	H
	POP	PSW
	MOV	B,A
	JMP	L9B7
;______________________________
FNLN:
LB56:	MOV	A,C
	DCR	A
	ADI	81H
	JNC	LB63
	MOV	H,C
	LXI	B,00FFH
	MOV	A,B
	RET
LB63:	MOV	B,C
	MVI	C,40H
	MOV	A,D
	CPI	6BH
	JC	LB6E
	DCR	C
	INR	B
LB6E:	PUSH	B
	CALL	LB0F
	MOV	H,C
	XTHL
	PUSH	D
	MOV	A,H
	SUI	40H
	CALL	L91B
	MVI	B,3FH
	LXI	H,62E4H
	CALL	L9B7
	POP	H
	POP	PSW
	MOV	B,A
	JMP	L819

;-------------------------- EXP
LB89:	MOV	A,C
	ADD	A
	CPI	5AH
	JC	LBD9
	MOV	B,C
	PUSH	B
	PUSH	D
	MVI	B,36
	LXI	H,612CH
	CALL	L9B7
	MVI	B,39H
	LXI	H,3F21H
	CALL	L819
	POP	H
	POP	PSW
	MOV	B,A
	PUSH	PSW
	PUSH	H
	CALL	L9B7
	MVI	B,3BH
	LXI	H,0C6A9H
	CALL	L819
	POP	H
	POP	PSW
	MOV	B,A
	PUSH	PSW
	PUSH	H
	CALL	L9B7
	MVI	B,3DH
	LXI	H,0EBEFH
	CALL	L819
	POP	H
	POP	PSW
	MOV	B,A
	PUSH	PSW
	PUSH	H
	CALL	L9B7
	MVI	B,3FH
	LXI	H,62E4H
	CALL	L819
	POP	H
	POP	PSW
	MOV	B,A
	CALL	L9B7
LBD9:	MVI	B,40H
	LXI	H,0000H
	JMP	L819
;______________________________
FNEN:
LBE1:	MVI	B,3FH
	LXI	H,62E4H
	MOV	A,C
	INR	A
	ADD	A
	CNZ	LA16
;______________________________
FN2N:
	MOV	A,C
	ANA	A
	JZ	LBD9
	CMA
	RAR
	MOV	L,A
	MOV	A,C
	ADD	A
	CPI	8EH
	JNC	L8C5
	MVI	B,0E0H
	MOV	B,L
	PUSH	D
	PUSH	B
	CALL	L947
	PUSH	D
	CALL	L920
	MOV	A,C
	POP	B
	POP	H
	MOV	B,L
	MOV	L,C
	XTHL
	MOV	C,A
	CALL	L807
	CALL	LB89
	MOV	A,C
	POP	B
	ADD	C
	MOV	C,A
	SUB	A
	JMP	L8BA

;------------------------- SIN,COS
LC1C:	PUSH	D
	MOV	A,C
	PUSH	PSW
	ADD	A
	CPI	58H
	JC	LC51
	CALL	L9B4
	PUSH	D
	MOV	B,C
	PUSH	B
	LXI	H,2D91H
	MVI	B,0B8H
	CALL	L9B7
	LXI	H,465FH
	MVI	B,3CH
	CALL	L819
	POP	PSW
	MOV	B,A
	POP	H
	PUSH	H
	PUSH	PSW
	CALL	L9B7
	LXI	H,4ABCH
	MVI	B,0BFH
	CALL	L819
	POP	PSW
	MOV	B,A
	POP	H
	CALL	L9B7
LC51:	LXI	H,9220H
	MVI	B,40H
	CALL	L819
	POP	PSW
	MOV	B,A
	POP	H
	JMP	L9B7
LC5F:	MOV	A,C
	ADD	A
	CPI	58H
	JC	LC92
	CALL	L9B4
	PUSH	D
	MOV	B,C
	PUSH	B
	LXI	H,4E4CH
	MVI	B,0BAH
	CALL	L9B7
	LXI	H,03AFH
	MVI	B,3EH
	CALL	L819
	POP	PSW
	MOV	B,A
	POP	H
	PUSH	H
	PUSH	PSW
	CALL	L9B7
	LXI	H,3BD4H
	MVI	B,0C0H
	CALL	L819
	POP	PSW
	MOV	B,A
	POP	H
	CALL	L9B7
LC92:	LXI	H,0000H
	MVI	B,40H
	JMP	L819
;______________________________
FNTS:
LC9A:	MVI	H,00H
	JMP	LCA1
;______________________________
FNTC:
LC9F:	MVI	H,01H
LCA1:	MOV	A,C
	ADD	A
	ADI	68H
	MOV	B,C
	MVI	A,00
	MOV	C,A
	RC
	MOV	C,B
	PUSH	H
	PUSH	D
	PUSH	B
	CALL	L947
	PUSH	D
	CALL	L920
	POP	H
	POP	PSW
	MOV	B,A
	XTHL
	CALL	L807
	POP	H
	POP	PSW
	ADD	L
	RAR
	PUSH	PSW
	CNC	LC1C
	CC	LC5F
	POP	PSW
	RAR
	RNC
	JMP	L805
;______________________________
FNTG:
	CALL	LCDC
	RC
	JMP	LA16
LCD4:	LXI	H,9220H
	MVI	B,40H
	CALL	LA16
LCDC:	PUSH	B
	PUSH	D
	CALL	LC9F
	JC	LE8E
	MOV	A,C
	XCHG
	POP	D
	POP	B
	PUSH	H
	PUSH	PSW
	CALL	LC9A
	JMP	LDB1
;______________________________
FACN:
	CALL	LCFC
	RC
	MVI	B,40H
LCF6:	LXI	H,9220H
	JMP	L807
;______________________________
FASN:
LCFC:	MOV	A,C
	PUSH	PSW
	PUSH	D
	CALL	L9B4
	JC	LE8E
	LXI	H,0000
	MVI	B,40H
	CALL	L807
	JC	LE8E
	CALL	LDFB
	JC	LE8E
	POP	H
	POP	PSW
	MOV	B,A
	CALL	LA13
;______________________________
FATN:
LD1C:	PUSH	B
	MOV	A,C
	ANI	7FH
	MOV	C,A
	LXI	H,0001H
	MVI	B,40H
	CALL	LA88
	POP	B
	JM	LD3E
	MOV	A,C
	PUSH	PSW
	CALL	LA0E
	CALL	LD3E
	POP	PSW
	ANI	80H
	ORI	40H
	MOV	B,A
	JMP	LCF6
LD3E:	MOV	A,C
	PUSH	PSW
	PUSH	D
	CALL	L9B4
	MOV	A,C
	PUSH	PSW
	PUSH	D
	LXI	H,273DH
	MVI	B,0B9H
	CALL	L9B7
	LXI	H,2144H
	MVI	B,3BH
	CALL	L819
	POP	H
	POP	PSW
	PUSH	PSW
	PUSH	H
	MOV	B,A
	CALL	L9B7
	LXI	H,60F8H
	MVI	B,0BCH
	CALL	L819
	POP	H
	POP	PSW
	PUSH	PSW
	PUSH	H
	MOV	B,A
	CALL	L9B7
	LXI	H,551BH
	MVI	B,3EH
	CALL	L819
	POP	H
	POP	PSW
	MOV	B,A
	CALL	L9B7
	LXI	H,0000
	MVI	B,40H
	CALL	L819
	POP	H
	POP	PSW
	MOV	B,A
	JMP	LA13
;______________________________
FNRP:
	PUSH	H
	PUSH	B
	PUSH	D
	MVI	A,80H
	ANA	C
	MOV	A,B
	RAL
	PUSH	PSW
	CALL	LA13
	CALL	LD1C
	POP	PSW
	JP	LDA8
	LXI	H,9220H
	MVI	A,82H
	RAR
	MOV	B,A
	CALL	L819
LDA8:	MOV	A,C
	XCHG
	POP	D
	POP	B
	XTHL
	PUSH	PSW
	CALL	LDDF
LDB1:	JC	LE8E
	POP	PSW
	POP	H
	MOV	B,A
	RET
;______________________________
FNPR:
	CALL	L814
	PUSH	H
	PUSH	B
	CALL	LCD4
	JC	LE8E
	POP	PSW
	XTHL
	PUSH	B
	PUSH	H
	MOV	B,A
	PUSH	B
	CALL	L9B7
	XCHG
	MOV	A,C
	POP	B
	POP	D
	MOV	C,A
	POP	PSW
	XTHL
	PUSH	B
	MOV	C,A
	XCHG
	CALL	L9B7
	MOV	A,C
	POP	B
	POP	H
	MOV	B,C
	MOV	C,A
	RET
;______________________________
FNNO:
LDDF:	PUSH	H
	PUSH	B
	CALL	L9B4
	JC	LE8E
	POP	PSW
	POP	H
	MOV	B,C
	PUSH	D
	PUSH	B
	MOV	C,A
	XCHG
	CALL	L9B4
	JC	LE8E
	POP	PSW
	POP	H
	MOV	B,A
	CALL	L819
	RC
;______________________________
FNRT:
LDFB:	SUB	A
	ORA	C
	RZ
	LXI	H,0000
	MVI	B,3FH
;______________________________
FNPO:	PUSH	H
	PUSH	B
	CALL	LB56
	MOV	A,C
	POP	B
	POP	H
	MOV	C,A
	RC
	CALL	L9B7
	JNC	LBE1
	RET
;______________________________
FNFD:
	PUSH	H
	LXI	B,600H
	LXI	D,0
	LXI	H,0
	MVI	A,00
	XTHL
	PUSH	PSW
	CALL	LEEF
	JNC	LE3B
	CALL	LEFC
	JC	LE93
	PUSH	H
	LXI	H,0005H
	DAD	SP
	MOV	M,A
	POP	H
LE35:	CALL	LEEF
	JC	LE9B
LE3B:	CALL	LF07
	DCR	B
	JNZ	LE35
	CALL	LEEF
	CMC
	JC	LE8E
	JMP	LE9B
LE4C:	CALL	LEEF
	JNC	LE65
	CALL	LEFC
	JC	LE90
	JP	LE5F
	XTHL
	MVI	L,0FFH
	XTHL
LE5F:	CALL	LEEF
	JC	LEDC
LE65:	PUSH	D
	PUSH	B
	MOV	E,A
	CALL	LEEF
	CC	LEE5
	CALL	LF07
	MOV	A,E
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