 NAM FLOAT (STRUBAL +)
*
 CMN RUNSTK,80
 CMN ACCUM1,2
 CMN ACCUM2,2
 CMN ACCUM3,2
 CMN ACCUM4,2
 CMN ACCUM5,9
 CMN ADRTO,2
 CMN ADRFM,2
*
 ENT FTAREG
 ENT FTCREG
 ENT FFDREG
 ENT FADD
 ENT FSUB
 ENT FMUL
 ENT FDIV
 ENT MOVER
 ENT DIGSET
*
 EXT DIVERR
*
* SET PRECISION OF FLOATING POINT
*
DIGSET STX ACCUM1
 LDAA ACCUM1+1
 BMI DFAULT
 CMPA #4
 BLT DFAULT
 CMPA #14
 BGT DFAULT
 ASRA
 STAA NB
 ASLA
 CLRB
DIGST2 CMPA #10
 BCS DIGST3
 SUBA #10
 ADDB #$10
 BRA DIGST2
DIGST3 ABA
 DAA
 STAA ND
 LDX #AREG
 LDAA #7
 SUBA NB
 BEQ DIGST5
DIGST4 DEX
 DECA
 BNE DIGST4
DIGST5 STX AMOD
 BSR XINC7
 STX BMOD
 BSR XINC7
 STX CMOD
 BSR XINC7
 STX DMOD
 BSR XINC7
 STX EMOD
 RTS
DFAULT LDAA #7
 STAA NB
 LDAA #$14
 STAA ND
 LDX #AREG
 BRA DIGST5
XINC7 INX
 INX
 INX
 INX
 INX
 INX
 INX
 RTS
NB FCB 7
ND FCB $14
AMOD FDB AREG
BMOD FDB BREG
CMOD FDB CREG
DMOD FDB DREG
EMOD FDB EREG
EXP2 RMB 2
EXP1 RMB 2
AREG RMB 7
BREG RMB 7
CREG RMB 7
DREG RMB 7
EREG RMB 7
 RMB 2
ADRSAV RMB 2
EXPSAV RMB 2
COUNTR RMB 1
FTAREG LDAB NB
 INCB
 INCB
 STX ADRFM
 LDX #AREG
 STX ADRTO
 BRA MOVER
FTCREG LDAB NB
 INCB
 INCB
 STX ADRFM
 LDX #CREG
 STX ADRTO
 BRA MOVER
FFDREG LDAB NB
 INCB
 INCB
 STX ADRTO
 LDX #DREG
 STX ADRFM
MOVER LDX ADRFM
 LDAA 0,X
 INX
 STX ADRFM
 LDX ADRTO
 STAA 0,X
 INX
 STX ADRTO
 DECB
 BNE MOVER
 RTS
* ADD ROUTINE
ADD LDX BMOD
 LDAB NB
 CLC
ADD10 DEX
 LDAA 0,X
 ADCA 14,X
 DAA
 STAA 28,X
 DECB
 BNE ADD10
 STAB EREG-1
 BCC ADD20
 INC EREG-1
ADD20 LDX #EREG-1
ADD30 DEX
 STAB 0,X
 CPX #DREG
 BNE ADD30
 RTS
* SUB ROUTINE
SUB LDX CMOD
 LDAB NB
SUB10 DEX
 LDAA #$99
 SUBA 7,X
 STAA 7,X
 DECB
 BNE SUB10
 LDX BMOD
 LDAB NB
 SEC
SUB20 DEX
 LDAA 0,X
 ADCA 14,X
 DAA
 STAA 28,X
 DECB
 BNE SUB20
 BCS SUB40
 LDX #EREG-1
 LDAB NB
SUB30 INX
 LDAA #$99
 SUBA 0,X
 STAA 0,X
 DECB
 BNE SUB30
 LDX EMOD
 LDAB NB
 SEC
SUB35 DEX
 LDAA #0
 ADCA 7,X
 DAA
 STAA 7,X
 DECB
 BNE SUB35
 LDAA #$80
 STAA 0,X
 CLRA
 LDAB NB
 DECB
 BRA SUB50
SUB40 LDX #DREG
 LDAB NB
 DECB
 CLRA
 STAA 0,X
SUB50 INX
 STAA 0,X
 DECB
 BNE SUB50
 RTS
* MULTIPLY ROUTINE
MUL LDX #EREG
 LDAB #14
 CLRA
MUL05 DEX
 STAA 7,X
 DECB
 BNE MUL05
 LDAB #7
MUL10 DEX
 STAA 0,X
 DECB
 BNE MUL10
 LDX #BREG
MUL15 DEX
 CPX #AREG-1
 BNE MUL20
 RTS
MUL20 STX ADRSAV
 LDAB 0,X
 ANDB #$F
 BEQ MUL30
MUL25 BSR MUL45
 DECB
 BNE MUL25
MUL30 BSR MUL55
 LDAB 0,X
 ANDB #$F0
 BEQ MUL40
 LSRB
 LSRB
 LSRB
 LSRB
MUL35 BSR MUL45
 DECB
 BNE MUL35
MUL40 BSR MUL35
 BRA MUL15
MUL45 CLC
MUL50 LDAA 14,X
 ADCA 28,X
 DAA
 STAA 28,X
 DEX
 CPX #AREG-8
 BNE MUL50
 LDX ADRSAV
 RTS
MUL55 LDAA #4
MUL60 LDAB #14
 LDX #DREG
 CLC
MUL65 DEX
 ROL 0,X
 DECB
 BNE MUL65
 DECA
 BNE MUL60
 LDX ADRSAV
 RTS
* FLOATING ADD ROUTINE
FADD LDX #AREG-2
 LDAB NB
 INCB
 INCB
FADD01 LDAA 2,X
 STAA 0,X
 INX
 DECB
 BNE FADD01
 LDX CREG
 STX EXP2
 LDX #CREG
 LDAB NB
FADD02 LDAA 2,X
 STAA 0,X
 INX
 DECB
 BNE FADD02
 LDX #AREG
 LDAB NB
FADD03 LDAA 0,X
 STAA 7,X
 INX
 DECB
 BNE FADD03
 LDAA EXP1
 ANDA #$20
 BEQ FADD04
 JMP FADD20
FADD04 LDAA EXP2
 ANDA #$20
 BEQ FADD06
 JMP FADD16
FADD06 LDAA EXP1
 ANDA #$40
 STAA COUNTR
 LDAB EXP2
 ANDB #$40
 CBA
 BEQ FADD08
 LDAA EXP2
 ANDA #$1F
 STAA EXPSAV
 LDAB EXP1
 ANDB #$1F
 LDAA EXP2+1
 ADDA EXP1+1
 DAA
 STAA EXPSAV+1
 TBA
 ADCA EXPSAV
 DAA
 STAA EXPSAV
 BRA FADD12
FADD08 CLR COUNTR
 LDAA EXP1
 ANDA #$1F
 STAA EXPSAV
 LDAA #$99
 LDAB EXP2
 ANDB #$1F
 SBA
 TAB
 LDAA #$99
 SUBA EXP2+1
 SEC
 ADCA EXP1+1
 DAA
 STAA EXPSAV+1
 TBA
 ADCA EXPSAV
 DAA
 STAA EXPSAV
 BCS FADD10
 LDAA #$99
 INC  COUNTR
 TAB
 SUBB EXPSAV
 SUBA EXPSAV+1
 ADDA #1
 DAA
 STAA EXPSAV+1
 TBA
 ADCA #0
 DAA
 STAA EXPSAV
FADD10 LDAA EXP1
 ANDA #$40
 BEQ FADD12
 DEC COUNTR
FADD12 LDAA EXPSAV
 BNE FADD14
 LDAA EXPSAV+1
 CMPA ND
 BLT FADD26
FADD14 LDAA COUNTR
 BNE FADD20
FADD16 LDX #AREG-2
 LDAB NB
 INCB
 INCB
FADD18 LDAA 0,X
 STAA 23,X
 INX
 DECB
 BNE FADD18
 BRA FADD24
FADD20 LDX EXP2
 STX DREG
 LDX #CREG
 LDAB NB
FADD22 LDAA 0,X
 STAA 9,X
 INX
 DECB
 BNE FADD22
FADD24 JMP FADD72
FADD26 LDX #AREG
 LDAA COUNTR
 BNE FADD30
 LDX #CREG
FADD30 STX ADRSAV
 LDAA EXPSAV+1
 LSRA
 BCC FADD36
 LDAA #4
FADD32 LDAB NB
 LDX ADRSAV
 CLC
FADD34 ROR 0,X
 INX
 DECB
 BNE FADD34
 DECA
 BNE FADD32
 DEC EXPSAV+1
FADD36 LDAA EXPSAV+1
 BEQ FADD42
FADD38 LDX ADRSAV
 LDAB #6
FADD40 DEX
 LDAA 6,X
 STAA 7,X
 DECB
 BNE FADD40
 CLR 6,X
 LDAA #$98
 ADDA EXPSAV+1
 DAA
 STAA EXPSAV+1
 BNE FADD38
FADD42 LDX #EXP2
 LDAA COUNTR
 BNE FADD44
 LDX #EXP1
FADD44 LDAA 0,X
 ANDA #$5F
 LDAB EXP1
 ANDB #$80
 ABA
 STAA EXPSAV
 LDAA 1,X
 STAA EXPSAV+1
 LDAA EXP1
 EORA EXP2
 ANDA #$80
 BEQ FADD54
 JSR SUB
 LDAA DREG
 EORA EXPSAV
 STAA DREG
 LDAA EXPSAV+1
 STAA DREG+1
 LDX #DREG
 LDAB NB
FADD50 LDAA 7,X
 STAA 2,X
 INX
 DECB
 BNE FADD50
 LDX #DREG
 JSR PAK
 JMP FADD72
FADD54 JSR ADD
 LDAA EREG-1
 BNE FADD60
 LDX EXPSAV
 STX DREG
 LDX #DREG
 LDAB NB
 BRA FADD50
FADD60 LDAA EXPSAV
 ANDA #$40
 BNE FADD64
 LDAA EXPSAV
 TAB
 ANDA #$1F
 STAA DREG
 ANDB #$C0
 STAB EXPSAV
 LDAA EXPSAV+1
 ADDA #2
 DAA
 STAA DREG+1
 LDAA #0
 ADCA DREG
 DAA
 TAB
 ANDA #$1F
 ANDB #$20
 LSRB
 ABA
 LDAB EXPSAV
 BRA FADD68
FADD64 LDAA EXPSAV
 TAB
 ANDA #$1F
 STAA DREG
 ANDB #$C0
 LDAA EXPSAV+1
 ADDA #$98
 DAA
 STAA DREG+1
 LDAA #$99
 ADCA DREG
 DAA
 BCS FADD68
 LDAA #2
 SUBA EXPSAV+1
 STAA DREG+1
 CLRA
 ANDB #$80
FADD68 ABA
 STAA DREG
 LDX #DREG
 LDAB NB
FADD70 LDAA 6,X
 STAA 2,X
 INX
 DECB
 BNE FADD70
FADD72 LDX EXP1
 STX AREG
 LDX #AREG
 LDAB NB
FADD74 LDAA 7,X
 STAA 2,X
 INX
 DECB
 BNE FADD74
 LDX #DREG
 JSR PAK
 RTS
* FLOATING SUB ROUTINE
FSUB LDAA #$80
 EORA CREG
 STAA CREG
 JMP FADD
* FLOATING MULTIPLY ROUTINE
FMUL LDX CREG
 STX EXP2
 LDX #AREG-2
 LDAB NB
 INCB
 INCB
FMUL10 LDAA 2,X
 STAA 0,X
 INX
 DECB
 BNE FMUL10
 LDX #CREG
 LDAB NB
FMUL20 LDAA 2,X
 STAA 0,X
 INX
 DECB
 BNE FMUL20
 JSR MUL
 LDX #DREG
 LDAB #14
FMUL30 DEX
 LDAA 14,X
 STAA 16,X
 DECB
 BNE FMUL30
 LDX BMOD
 LDAB NB
FMUL40 DEX
 LDAA 0,X
 STAA 2,X
 DECB
 BNE FMUL40
 LDAA EXP1
 EORA EXP2
 ANDA #$40
 BEQ FMUL50
 LDAB EXP2
 ANDB #$1F
 LDAA #$99
 SBA
 STAA DREG
 LDAA #$99
 SUBA EXP2+1
 SEC
 ADCA EXP1+1
 DAA
 STAA DREG+1
 LDAA EXP1
 ANDA #$1F
 ADCA DREG
 DAA
 BCS FMUL60
 LDAA #$99
 TAB
 SUBB DREG
 SUBA DREG+1
 ADDA #1
 DAA
 STAA DREG+1
 TBA
 ADCA #0
 DAA
 LDAB EXP2
 ANDB #$40
 ABA
 BRA FMUL70
FMUL50 LDAB EXP2
 ANDB #$1F
 STAA EXPSAV
 LDAA EXP2+1
 CLC
 ADCA EXP1+1
 DAA
 STAA DREG+1
 LDAA EXP1
 ANDA #$1F
 ADCA EXPSAV
 DAA
FMUL60 LDAB EXP1
 ANDB #$40
 ABA
FMUL70 LDAB EXP1
 EORB EXP2
 ANDB #$80
 ABA
 STAA DREG
 LDX #DREG
 JSR PAK
 RTS
PAK STX ADRSAV
 LDAA 0,X
 ANDA #$1F
 STAA EXPSAV
 CLR COUNTR
PAK05 LDX ADRSAV
 LDAA 2,X
 BNE PAK15
 LDAB NB
 DECB
PAK10 LDAA 3,X
 STAA 2,X
 INX
 DECB
 BNE PAK10
 CLR 2,X
 LDAA COUNTR
 ADDA #2
 DAA
 STAA COUNTR
 CMPA ND
 BLT PAK05
 LDAA #$20
 LDX ADRSAV
 STAA 0,X
 CLR 1,X
 RTS
PAK15 LDAB COUNTR
 BEQ PAK30
 LDAA 0,X
 ANDA #$40
 BEQ PAK20
 LDAA 1,X
 ABA
 DAA
 STAA 1,X
 LDAA #0
 ADCA EXPSAV
 DAA
 TAB
 ANDA #$1F
 ANDB #$20
 LSRB
 ABA
 STAA EXPSAV
 BRA PAK30
PAK20 LDAA #$99
 SBA
 SEC
 ADCA 1,X
 DAA
 TAB
 LDAA #$99
 ADCA EXPSAV
 DAA
 BCC PAK25
 STAA EXPSAV
 STAB 1,X
 LDAB COUNTR
  BRA PAK30
PAK25 LDAA #$99
 SUBA EXPSAV
 TAB
 LDAA #$99
 SUBA 1,X
 SEC
 ADCA COUNTR
 DAA
 STAA 1,X
 TBA
 ADCA #0
 DAA
 STAA EXPSAV
 LDAA 0,X
 ORAA #$40
 STAA 0,X
PAK30 LDAA 2,X
 ANDA #$F0
 BNE PAK45
 LDAA #1
 STAA COUNTR
 LDAA #4
PAK35 LDAB #7
 LDX ADRSAV
 SUBB NB
 BEQ PAK37
PAK36 DEX
 DECB
 BNE PAK36
PAK37 LDAB NB
 CLC
PAK40 DEX
 ROL 9,X
 DECB
 BNE PAK40
 DECA
 BNE PAK35
 LDX ADRSAV
 JMP PAK15
PAK45 LDAA 0,X
 ANDA #$C0
 ORAA EXPSAV
 STAA 0,X
 RTS
* DIVIDE ROUTINE
DIV LDX #EREG
 LDAB #14
 CLRA
DIV04 DEX
 STAA 7,X
 DECB
 BNE DIV04
 LDAB #7
DIV08 DEX
 STAA 0,X
 DECB
  BNE DIV08
 CLR AREG-1
 LDAA #4
DIV12 LDAB NB
 INCB
 LDX BMOD
 CLC
DIV16 DEX
 ROL 0,X
 DECB
 BNE DIV16
 DECA
 BNE DIV12
 LDAB #7
 SUBB NB
 LDAA #14
 SBA
 ASLA
 STAA COUNTR
DIV20 BSR DIV60
DIV24 BSR DIV72
 BCC DIV28
 LDX EMOD
 INC 6,X
 BRA DIV24
DIV28 BSR DIV60
 DEC COUNTR
 BEQ DIV40
 BSR DIV72
 LDAA #4
DIV32 LDAB #28
 LDX #EREG
 CLC
DIV36 DEX
 ROL 7,X
 DECB
 BNE DIV36
 DECA
 BNE DIV32
 BRA DIV20
DIV40 LDAA #4
DIV44 LDAB NB
 INCB
 LDX #AREG-1
 CLC
DIV48 ROR 0,X
 INX
 DECB
 BNE DIV48
 DECA
 BNE DIV44
DIV52 LDAB #7
 STAB COUNTR
 LDX #EREG
DIV56 DEX
 LDAA 0,X
 LDAB 7,X
 STAA 7,X
 STAB 0,X
 DEC COUNTR
 BNE DIV56
 RTS
DIV60 LDAB NB
 INCB
 LDX #AREG-1
DIV64 LDAA #$99
 SUBA 0,X
  STAA 0,X
 INX
 DECB
 BNE DIV64
 SEC
 LDAB NB
 INCB
 LDX BMOD
DIV68 DEX
 LDAA #0
 ADCA 0,X
 DAA
 STAA 0,X
 DECB
 BNE DIV68
 RTS
DIV72 LDAB NB
 INCB
 LDX BMOD
 CLC
DIV76 DEX
 LDAA 0,X
 ADCA 8,X
 DAA
 STAA 8,X
 DECB
 BNE DIV76
 RTS
* FLOATING DIVIDE
FDIV LDAA AREG
 ANDA #$20
 BEQ FDIV04
 JSR DIVERR
FDIV04 LDX AREG
 STX EXPSAV
 LDX CREG
 STX EXP2
 LDX #AREG
 LDAB NB
FDIV09 LDAA 2,X
 STAA 0,X
 INX
 DECB
 BNE FDIV09
 LDX #CREG
 LDAB NB
FDIV12 LDAA 2,X
 STAA 0,X
 INX
 DECB
 BNE FDIV12
 JSR DIV
 LDX BMOD
 LDAB NB
FDIV16 DEX
 LDAA 0,X
 STAA 2,X
 DECB
 BNE FDIV16
 LDX EXPSAV
 STX AREG
 STX EXP1
 LDX EMOD
 DEX
 LDAB NB
FDIV20 LDAA 0,X
 STAA 2,X
 DEX
 DECB
 BNE FDIV20
 LDAA 14,X
 BEQ FDIV32
 STAA 2,X
 LDX EMOD
 LDAB NB
FDIV22 LDAA 0,X
 STAA 1,X
 DEX
 DECB
 BNE FDIV22
 LDAA EXP2
 ANDA #$40
 BNE FDIV24
 LDAA EXP2
 TAB
 ANDA #$1F
 STAA DREG
 ANDB #$C0
 STAB EXP2
 LDAA EXP2+1
 ADDA #2
 DAA
 STAA DREG+1
 LDAA #0
 ADCA DREG
 DAA
 TAB
 ANDA #$1F
 ANDB #$20
 LSRB
 ABA
 LDAB EXP2
 BRA FDIV28
FDIV24 LDAA EXP2
 TAB
 ANDA #$1F
 STAA DREG
 ANDB #$C0
 LDAA EXP2+1
 ADDA #$98
 DAA
 STAA DREG+1
 LDAA #$99
 ADCA DREG
 DAA
 BCS FDIV28
 LDAA #2
 SUBA EXP2+1
 STAA DREG+1
 CLRA
 ANDB #$80
FDIV28 ABA
 STAA EXP2
 LDAA DREG+1
 STAA EXP2+1
FDIV32 LDAA EXP1
 EORA #$40
 STAA EXP1
 EORA EXP2
 ANDA #$40
 BEQ FDIV36
 LDAB EXP2
 ANDB #$1F
 LDAA #$99
 SBA
 STAA DREG
 LDAA #$99
 SUBA EXP2+1
 SEC
 ADCA EXP1+1
 DAA
 STAA DREG+1
 LDAA EXP1
 ANDA #$1F
 ADCA DREG
 DAA
 BCS FDIV40
 LDAA #$99
 TAB
 SUBB DREG
 SUBA DREG+1
 ADDA #1
 DAA
 STAA DREG+1
 TBA
 ADCA #0
 DAA
 LDAB EXP2
 ANDB #$40
 ABA
 BRA FDIV44
FDIV36 LDAB EXP2
 ANDB #$1F
 STAA EXPSAV
 LDAA EXP2+1
 CLC
 ADCA EXP1+1
 DAA
 STAA DREG+1
 LDAA EXP1
 ANDA #$1F
 ADCA EXPSAV
 DAA
 TAB
 ANDA #$1F
 ANDB #$20
 LSRB
 ABA
FDIV40 LDAB EXP1
 ANDB #$40
 ABA
FDIV44 LDAB EXP1
 EORB EXP2
 ANDB #$80
 ABA
 STAA DREG
 LDX #DREG
 JSR PAK
 RTS
 END
