TITLE 'FLOATING POINT MATH LIBRARY'›*›* BY FRANK PARIS›* JUNE 12, 1983›* COPYRIGHT (C) 1983›*› ORG $2DC0› JMP CAFP› JMP CFASC› JMP CIFP› JMP CFPI› JMP CFSUB› JMP CFADD› JMP CFMUL› JMP CFDIV› JMP CEXP› JMP CEXP10› JMP CLOG› JMP CLOG10›*›* EQUATES TO FLOATING POINT ROM ROUTINES›*›AFP EQU $D800›FASC EQU $D8E6›IFP EQU $D9AA›FPI EQU $D9D2›FSUB EQU $DA60›FADD EQU $DA66›FMUL EQU $DADB›FDIV EQU $DB28›EXP EQU $DDC0›EXP10 EQU $DDCC›LOG EQU $DECD›LOG10 EQU $DED1›INBUFF EQU $00F3›CIX EQU $00F2›FR0 EQU $00D4›FR1 EQU $00E0›*›* ATASCII TO FLOATING POINT›*›CAFP PLA› PLA› STA INBUFF+1› PLA› STA INBUFF› LDA #0› STA CIX› PLA› STA ZUB+2› PLA› STA ZUB+1› JSR AFP› BCS ERROR› JSR MZUB›NOERR LDA #0›COMMON TAX› RTS›ERROR LDA #$FF› JMP COMMON››*›* FLOATING POINT TO ATASCII›*›CFASC PLA› PLA› STA UBZ+2› PLA› STA UBZ+1› PLA› STA UA+2› STA UAEX+2› STA UAEY+2› PLA› STA UA+1› STA UAEX+1› STA UAEY+1› JSR MUBZ› JSR FASC› LDA INBUFF› STA FPALUP+1› LDA INBUFF+1› STA FPALUP+2› LDX #0›FPALUP LDA FPALUP,X› BMI DONE›UA STA UA,X› INX› JMP FPALUP›DONE AND #$7F›UAEX STA UAEX,X› INX› LDA #0›UAEY STA UAEY,X› RTS›*›* INTEGER TO FLOATING POINT›*›CIFP PLA› PLA› STA FR0+1› PLA› STA FR0› PLA› STA ZUB+2› PLA› STA ZUB+1› JSR IFP› JSR MZUB› RTS›*›* FLOATING POINT TO INTEGER›*›CFPI PLA› PLA› STA UBZ+2› PLA› STA UBZ+1› PLA› STA FR1+1› PLA› STA FR1› JSR MUBZ› JSR FPI› BCS ERROR1› LDY #0› LDA FR0› STA (FR1),Y› INY› LDA FR0+1› STA (FR1),Y› JMP NOERR›ERROR1 JMP ERROR›*›* FLOATING POINT SUBTRACTION›*›CFSUB PLA› PLA› STA UBZ+2› PLA› STA UBZ+1› PLA› STA UBO+2› PLA› STA UBO+1› PLA› STA ZUB+2› PLA› STA ZUB+1› JSR MUBZ› JSR MUBO› JSR FSUB› BCS ERROR1› JSR MZUB› JMP NOERR›*›* FLOATING POINT ADDITION›*›CFADD PLA› PLA› STA UBZ+2› PLA› STA UBZ+1› PLA› STA UBO+2› PLA› STA UBO+1› PLA› STA ZUB+2› PLA› STA ZUB+1› JSR MUBZ› JSR MUBO› JSR FADD› BCS ERROR1› JSR MZUB› JMP NOERR›*›* FLOATING POINT MULTIPLICATION›*›CFMUL PLA› PLA› STA UBZ+2› PLA› STA UBZ+1› PLA› STA UBO+2› PLA› STA UBO+1› PLA› STA ZUB+2› PLA› STA ZUB+1› JSR MUBZ› JSR MUBO› JSR FMUL› BCS ERROR2› JSR MZUB› JMP NOERR›ERROR2 JMP ERROR›*›* FLOATING POINT DIVISION›*›CFDIV PLA› PLA› STA UBZ+2› PLA› STA UBZ+1› PLA› STA UBO+2› PLA› STA UBO+1› PLA› STA ZUB+2› PLA› STA ZUB+1› JSR MUBZ› JSR MUBO› JSR FDIV› BCS ERROR2› JSR MZUB› JMP NOERR›*›* FLOATING POINT EXPONENTIATION - e**x›*›CEXP PLA› PLA› STA UBZ+2› PLA› STA UBZ+1› PLA› STA ZUB+2› PLA› STA ZUB+1› JSR MUBZ› JSR EXP› BCS ERROR2› JSR MZUB› JMP NOERR›*›* FLOATING POINT EXPONENTIATION - 10**x›*›CEXP10 PLA› PLA› STA UBZ+2› PLA› STA UBZ+1› PLA› STA ZUB+2› PLA› STA ZUB+1› JSR MUBZ› JSR EXP10› BCS ERROR3› JSR MZUB› JMP NOERR›*›* FLOATING POINT NATURAL LOGARITHM›*›CLOG PLA› PLA› STA UBZ+2› PLA› STA UBZ+1› PLA› STA ZUB+2› PLA› STA ZUB+1› JSR MUBZ› JSR LOG› JMP ERROR3› JSR MZUB› JMP NOERR›*›* FLOATING POINT BASE 10 LOGARITHM›*›CLOG10 PLA› PLA› STA UBZ+2› PLA› STA UBZ+1› PLA› STA ZUB+2› PLA› STA ZUB+1› JSR MUBZ› JSR LOG10› BCS ERROR3› JSR MZUB› JMP NOERR›ERROR3 JMP ERROR›*›* MOVE FR0 TO USER BUFFER›*›MZUB LDX #0›MZUBLP LDA FR0,X›ZUB STA ZUB,X› INX› CPX #6› BNE MZUBLP› RTS›*›* MOVE USER BUFFER TO FR0›*›MUBZ LDX #0›UBZ LDA UBZ,X› STA FR0,X› INX› CPX #6› BNE UBZ› RTS›*›* MOVE USER BUFFER TO FR1›*›MUBO LDX #0›UBO LDA UBO,X› STA FR1,X› INX› CPX #6› BNE UBO› RTS›