 .OPT NO LIST›;  SAVE #D1:FLOAT2.M65›;›;›;  LOAD #D1:CHARSET1.M65›  LIST  ›;›NORM› LDX #0      for add norm  B› STX FRE     shift in a 0›;›NORM1› LDX #4› LDA FR0     get exponent› BEQ ?NDONE  done if 0›;›?NORM2› LDA FR0+1   get 1st mantissa› BNE ?TSTBIG if not 0, no shift› LDY #0›;›?NSH› LDA FR0+2,Y› STA FR0+1,Y› INY › CPY #5› BCC ?NSH› DEC FR0     decr exponent› DEX › BNE ?NORM2› LDA FR0+1   mantissa still 0?› BNE ?TSTBIG see if too big› STA FR0     else clear exponent› CLC › RTS ›;›?TSTBIG› LDA FR0     get absolute› AND #$7F    exponent› CMP #49+$40 less than 49+64?› BCC ?TSTUND Yes, test underflow› RTS ›?TSTUND  CMP #-49+$40 done if >=› BCS ?NDONE  ; -49+$40› JSR ZFR0    Else number = 0›;›?NDONE› CLC › RTS ›;›RSHFT0› LDX #FR0    Point to Fr0› BNE ?RSH›;›RSHFT1› LDX #FR1    Point to Fr1›;›?RSH› STX ZTEMP3  Save fr pointer› STA ZTEMP4  Save # bytes to shift› STA ZTEMP4+1 save for later›;›?RSH2› LDY #4      Get # bytes to move›;›?RSH1› LDA 4,X     Get char› STA 5,X     Store char› DEX         Point to next› DEY         Dec loop control› BNE ?RSH1   If more repeat› LDA #0      Get first byte› STA 5,X     store it› LDX ZTEMP3  Get Fr pointer› DEC ZTEMP4  Do we need to repeat?› BNE ?RSH2   If yes do it› LDA 0,X     Get exponent› CLC › ADC ZTEMP4+1 Sub # of shifts› STA 0,X     save new exponent› RTS ›;›RSHF0E› LDX #5*2    Get loop control›;›?NXTB1› LDA FR0,X   Get a byte› STA FR0+1,X Move it over one› DEX         Dec counter› BPL ?NXTB1  Move next byte› LDA #0      Get 0› STA FR0     Shift it in› RTS ›;›?CVFR0› STA ZTEMP4  Save decimal position› LDX #0      Set index into mantissa› LDY #0      Set index into output›;›?CVBYTE› JSR ?TSTDP  Put in DP now?› SEC         Dec DP position› SBC #1› STA ZTEMP4  Save it› LDA FR0+1,X Get from Fr0› LSR A       Shift out low order bits› LSR A       To get 1st digit› LSR A› LSR A› JSR ?STNUM  Go put number in buffer› LDA FR0+1,X Do second digit› AND #$0F    Strip high bits› JSR ?STNUM  Store in buffer› INX         Incr pointer› CPX #5      Done?› BCC ?CVBYTE If not do more›;›?TSTDP› LDA ZTEMP4  Get DP position› BNE ?TST1   If not 0, return› LDA #'.     Get ascii DP› JSR ?STCHAR Put in buffer›;›?TST1› RTS ›;›;›?STNUM› ORA #'0     Convert to ascii›;›?STCHAR› STA LBUFF,Y Put in Lbuff› INY         Incr. pointer› RTS ›;›?FNZERO› LDX #10     Point to last char in lbuff›;›?FN3› LDA LBUFF,X Get character› CMP #'.     Is it a DP?› BEQ ?FN1    If yes, go› CMP #'0     Is it a 0?› BNE ?FN2    Go if not› DEX         Decr. index› BNE ?FN3    Go always›;›?FN1› DEX         Decr. buffer index› LDA LBUFF,X Get last char›;›?FN2› RTS ›;›;›?GETDIG› JSR NIBSH0  Shift Fr0 left one nybble› LDA FRX     Get byte containing shifted nybble› AND #$0F    Strip high order bits› RTS ›;›?DECINB› SEC         Subtract one from inbuff› LDA INBUFF› SBC #1› STA INBUFF› LDA INBUFF+1› SBC #0› STA INBUFF+1› RTS ›;›MDESUP› LDA FR0     Get FR0 exponent› EOR FR1     Get Fr1 exponent› AND #$80    Strip all but sign bit› STA FRSIGN  Save sign› ASL FR1     Shift out sign in Fr1 exponent› LSR FR1     Restore Fr1 less sign› LDA FR0     Get Fr0 exponent› AND #$7F    Strip sign bit› RTS ›;›MDSUP› ORA FRSIGN  Or in sign bit› STA EEXP    Save exponent› LDA #0      Clear a› STA FR0     and Fr0› STA FR1     and Fr1› JSR MVFR12  Move Fr1 to Fr2› JSR NIBSH2  Shift Fr2 one nybble left› LDA FRX     Get shifted nybble› AND #$0F    Strip high order bits› STA FR2     Store to finish shift› LDA #5      Set loop control› STA ZTEMP1› JSR MVFR0E  Move Fr0 to Fre› JSR ZFR0    Clear Fr0› RTS ›;›FRA10› LDX #FR0+5  Point to last byte of sum› BNE ?F1›;›FRA20› LDX #FR0+5› BNE ?F2›;›FRA1E› LDX #FRE+5›;›?F1› LDY #FR1+5› BNE ?FRA›;›FRA2E› LDX #FRE+5›;›?F2› LDY #FR2+5›;›?FRA› LDA #5      Set loop control› STA ZTEMP4› CLC › SED         Decimal mode›;›?FRA1› LDA 0,X     Get 1st byte› ADC 0,Y     add› STA 0,X     store› DEX › DEY › DEC ZTEMP4  Decr loop control› BPL ?FRA1   til done› CLD         Clear decimal› RTS ›;›MVFR12› LDY #5      Move Fr1 to Fr2›;›?MV2› LDA FR1,Y› STA FR2,Y› DEY › BPL ?MV2› RTS ›;›MVFR0E› LDY #5      Move Fr0 to Fre›;›?MV1› LDA FR0,Y› STA FRE,Y› DEY › BPL ?MV1› RTS ›;›PLYEVL› STX FPTR2   save pointer to coefs B› STY FPTR2+1› STA PLYCNT› LDX # <PLYARG› LDY # >PLYARG› JSR FST0R   Save arg› JSR FMOVE   Arg->Fr1› LDX FPTR2› LDY FPTR2+1› JSR FLD0R   Coeff->Fr0 (init sum)› DEC PLYCNT  Done?› BEQ ?PLYOUT›;›?PLYEV1› JSR FMUL    sum*arg› BCS ?PLYOUT Overflow› CLC › LDA FPTR2   bump coeff pointer› ADC #FPREC› STA FPTR2› BCC ?PLYEV2› LDA FPTR2+1 across page› ADC #0› STA FPTR2+1›;›?PLYEV2› LDX FPTR2› LDY FPTR2+1› JSR FLD1R   Get next coeff› JSR FADD    sum*arg+coef› BCS ?PLYOUT overflow› DEC PLYCNT› BEQ ?PLYOUT› LDX # <PLYARG› LDY # >PLYARG› JSR FLD1R   Get arg again› BMI ?PLYEV1 Go always›;›?PLYOUT› RTS ›;›;›FLD0R› STX FLPTR   Set Flptr B› STY FLPTR+1›;›FLD0P› LDY #5      ; # bytes›;›FLD01› LDA (FLPTR),Y Move them› STA FR0,Y› DEY › BPL FLD01› RTS ›;›FLD1R› STX FLPTR   B› STY FLPTR+1›;›FLD1P› LDY #5›;›FLD11› LDA (FLPTR),Y Copy (Flptr)› STA FR1,Y   to Fr1› DEY › BPL FLD11› RTS ›;›FST0R› STX FLPTR   B› STY FLPTR+1›;›FST0P› LDY #5›;›FST01› LDA FR0,Y› STA (FLPTR),Y› DEY › BPL FST01› RTS ›;›FMOVE› LDX #5      aka MV0TO1  B›;›FMOVE1› LDA FR0,X   Copy Fr0 to Fr1› STA FR1,X› DEX › BPL FMOVE1› RTS ›EXP      LDX # <LOG10E e^x=10^(x^ln(10)) B› LDY # >LOG10E› JSR FLD1R› JSR FMUL› BCS EXPERR›;›EXP10› LDA #0      ;10^x B› STA XFMFLG  Clear transform flag› LDA FR0› STA SGNFLG  Remember arg sign› AND #$7F    and make +ve› STA FR0› SEC › SBC #$40› BMI EXP1    x<1 so use series directly› CMP #4› BPL EXPERR  arg to big› LDX # <FPSCR› LDY # >FPSCR› JSR FST0R   save arg› JSR FPI     make integer› LDA FR0› STA XFMFLG  save multiplier exponent› LDA FR0+1   check msb› BNE EXPERR  should be none› JSR IFP     Back to floating point› JSR FMOVE› LDX # <FPSCR› LDY # >FPSCR› JSR FLD0R   Get arg back› JSR FSUB    Arg-integer=fraction›;›EXP1› LDA #NPCOEF coefficients› LDX # <P10COF› LDY # >P10COF› JSR PLYEVL  p(x)› JSR FMOVE› JSR FMUL    p(x)*p(x)› LDA XFMFLG  did we transform arg› BEQ EXPSGN  No, leave result alone› CLC         i/2› ROR A› STA FR1› LDA #1      Get mantissa byte› BCC EXP2    Check bit shifted out of a› LDA #$10    i was odd, mantissa=10›;›EXP2› STA FR1+1› LDX #4› LDA #0›;›EXP3› STA FR1+2,X Clear rest of mantissa› DEX › BPL EXP3› LDA FR1     back to exponent› CLC › ADC #$40    bias it› BCS EXPERR  Too big› BMI EXPERR› STA FR1     Fr1=10^i› JSR FMUL    (10^i)*(10^f)›;›EXPSGN› LDA SGNFLG  arg<0?› BPL EXPOUT  No, done› JSR FMOVE   Yes, invert result› LDX # <FONE› LDY # >FONE› JSR FLD0R› JSR FDIV›;›EXPOUT› RTS         Done›;›;›EXPERR› SEC         Flag error› RTS         Quit›;›P10COF› .BYTE $3D,$17,$94,$19,0,0›; .FLOAT 0.0000179419› .BYTE $3D,$57,$33,$05,0,0›; .FLOAT 0.0000573305› .BYTE $3E,$05,$54,$76,$62,0›; .FLOAT 0.0005547662› .BYTE $3E,$32,$19,$62,$27,0›; .FLOAT 0.0032176227› .BYTE $3F,$01,$68,$60,$30,$36›; .FLOAT 0.0168603036› .BYTE $3F,$07,$32,$03,$27,$41›; .FLOAT 0.0732032741› .BYTE $3F,$25,$43,$34,$56,$75›; .FLOAT 0.02543345675› .BYTE $3F,$66,$27,$37,$30,$50›; .FLOAT 0.66273730505› .BYTE $40,$01,$15,$12,$92,$55›; .FLOAT 1.15129255555› .BYTE $3F,$99,$99,$99,$99,$99›; .FLOAT 0,99999999999›NPCOEF   =   [*-P10COF]/6›;›LOG10E› .BYTE $3F,$43,$42,$94,$48,$19›; .FLOAT 0.43429448190 log(e)›;›FONE› .BYTE $40,1,0,0,0,0›; .FLOAT 1›XFORM    STX FPTR2   z=(x-c)/(x+c) B› STY FPTR2+1› LDX # <PLYARG› LDY # >PLYARG› JSR FST0R   x to plyarg› LDX FPTR2› LDY FPTR2+1› JSR FLD1R› JSR FADD    x+c› LDX # <FPSCR› LDY # >FPSCR› JSR FST0R› LDX # <PLYARG› LDY # >PLYARG› JSR FLD0R› LDX FPTR2› LDY FPTR2+1› JSR FLD1R› JSR FSUB    x-c› LDX # <FPSCR› LDY # >FPSCR› JSR FLD1R› JSR FDIV    (x-c)/(x+c)=z› RTS ›;›LOG› LDA #1      ln(x) B› BNE LOGBTH›;›LOG10› LDA #0      log(x)  B›;›LOGBTH› STA SGNFLG  Use sign to remember entry› LDA FR0›; -----------› BEQ LOGERR  different from› BMI LOGERR  book› JMP LOG1    jump patch›;›LOGERR   SEC         Address = book+5› RTS         ;-----------›;›?XPATCH› SBC #$40    Addreses match› ASL A       book again› STA XFMFLG  Remember y› LDA FR0+1› AND #$F0› BNE LOG2› LDA #1› BNE LOG3›;›LOG2› INC XFMFLG  bump y› LDA #$10›;›LOG3› STA FR1+1   Set mantissa› LDX #4      Clear rest› LDA #0›;›LOG4› STA FR1+2,X› DEX › BPL LOG4› JSR FDIV›FLOG10   LDX # <SQR10 log(x) 1>=x<=10› LDY # >SQR10› JSR XFORM   z=(x-c)/(x+c) c*c=10› LDX # <FPSCR› LDY # >FPSCR› JSR FST0R   save z› JSR FMOVE› JSR FMUL    z*z› LDA #NLCOEF› LDX # <LGCOEF› LDY # >LGCOEF› JSR PLYEVL  p(z*z)› LDX # <FPSCR› LDY # >FPSCR› JSR FLD1R› JSR FMUL    z*p(z*z)› LDX # <FHALF› LDY # >FHALF› JSR FLD1R› JSR FADD    0.5+z*p(z*z)› JSR FMOVE› LDA #0› STA FR0+1› LDA XFMFLG› STA FR0› BPL LOG6› EOR #$FF    flip sign› CLC › ADC #1› STA FR0›;›LOG6› JSR IFP     leaves Fr1 alone› BIT XFMFLG› BPL LOG7› LDA #$80    Flip again› ORA FR0› STA FR0›LOG7     JSR FADD    ln(x)=ln(x)+y›;›LOGOUT› LDA SGNFLG› BEQ LOGDON  was log, not ln› LDX # <LOG10E ln(x)/log(e)› LDY # >LOG10E›; .FLOAT 3.16227766  sqr(10)› JSR FLD1R› JSR FDIV›;›LOGDON› CLC › RTS ›;›SQR10› .BYTE $40,$03,$16,$22,$77,$66›;›FHALF› .BYTE $3F,$50,0,0,0,0 B›; .FLOAT 0.5›;›LGCOEF› .BYTE $3F,$49,$15,$57,$11,$08›; .FLOAT 0.4915571108› .BYTE $BF,$51,$70,$49,$47,$08›; .FLOAT -0.5170494708› .BYTE $3F,$39,$20,$57,$61,$95›; .FLOAT 0.3920576195› .BYTE $BF,$04,$39,$63,$03,$55›; .FLOAT -0.0439630355› .BYTE $3F,$10,$09,$30,$12,$64›; .FLOAT 0.1009301264›; .FLOAT 0.7853981634›; pi/4=arctan(1.0)› .BYTE $3F,$09,$39,$08,$04,$60›; .FLOAT 0.0939080460› .BYTE $3F,$12,$42,$58,$47,$42›; .FLOAT 0.1242584742› .BYTE $3F,$17,$37,$12,$06,$08›; .FLOAT 0.1737120608› .BYTE $3F,$28,$95,$29,$71,$17›; .FLOAT 0.2895297117› .BYTE $3F,$86,$85,$88,$96,$44›; .FLOAT 0.8685889644›NLCOEF   =   [*-LGCOEF]/FPREC›;›ATCOEF› .BYTE $3E,$16,$05,$44,$49,$00 B›; .FLOAT 0.0016054449› .BYTE $BE,$95,$68,$38,$45,$00›; .FLOAT -0.00956834500› .BYTE $3F,$02,$68,$79,$94,$16›; .FLOAT 0.0268799416› .BYTE $BF,$04,$92,$78,$90,$80›; .FLOAT -0.0492789080› .BYTE $3F,$07,$03,$15,$20,$00›; .FLOAT 0.0703152000› .BYTE $BF,$08,$92,$29,$12,$44›; .FLOAT -0.0892291244› .BYTE $3F,$11,$08,$40,$09,$11›; .FLOAT 0.1108400911› .BYTE $BF,$14,$28,$31,$56,$04›; .FLOAT -0.1428315604› .BYTE $3F,$19,$99,$98,$77,$44›; .FLOAT 0.1999987744› .BYTE $BF,$33,$33,$33,$31,$13›; .FLOAT -0.3333333113›;›FP9S› .BYTE $3F,$99,$99,$99,$99,$99 B›; .FLOAT 0.9999999999›NATCF    =   [*-ATCOEF]/FPREC›;›PIOV4› .BYTE $3F,$78,$53,$98,$16,$34 B›;›LOG1› LDA FR0     Patch inserted› STA FR1     to make space in› SEC         log to check for› JMP ?XPATCH log(0) or ln(0)› .BYTE 0,0   unused›