0100 ; FPMAC.LIB 0110 ; 0120 FPMAC 0130 ; 0140 .IF .NOT .DEF OSEQU 0150 .ERROR "Must include OSEQU.LIB" 0160 .ENDIF 0170 ; 0180 ; floating point macros 0190 ; 0200 ; 0210 ; MACRO: @A2FP 0220 ; 0230 ; FORM: @A2FP inbuff 0240 ; 0250 ; converts 10 byte or less 0260 ; ascii number at inbuff to 0270 ; FP number in FR0 0280 ; 0290 .MACRO @A2FP 0300 LDA # <%1 0310 STA INBUFF 0320 LDA # >%1 0330 STA INBUFF+1 0340 LDA #0 0350 STA CIX 0360 JSR AFP ;[D800] 0370 BCC @B1 0380 JMP FPERROR 0390 @B1 NOP 0400 .ENDM 0410 ; 0420 ; 0430 ; 0440 ; MACRO: @FP2A 0450 ; 0460 ; FORM: @FP2A 0470 ; 0480 ; converts a FP number in FR0 to 0490 ; ascii and places it in LBUFF 0500 ; pointed to by INBUFF 0510 ; 0520 .MACRO @FP2A 0530 JSR FASC ;[D8E6] 0540 .ENDM 0550 ; 0560 ; 0570 ; 0580 ; MACRO: @FP2MEM 0590 ; 0600 ; FORM: @FP2MEM buffer 0610 ; 0620 ; moves reslut of FP to ASCII 0630 ; conversion to memory 0640 ; 0650 .MACRO @FP2MEM 0660 LDA # <%1 0670 STA TO 0680 LDA # >%1 0690 STA TO+1 0700 LDY #$FF 0710 @LOOP INY 0720 LDA (INBUFF),Y 0730 STA (TO),Y 0740 CMP #$80 0750 BCS @LOOP 0760 AND #$7F 0770 STA (TO),Y 0780 INY 0790 LDA #$9B 0800 STA (TO),Y 0810 .ENDM 0820 ; 0830 ; 0840 ; 0850 ; MACRO: @WRD2FP 0860 ; 0870 ; FORM: @WRD2FP 0880 ; 0890 ; converts a two byte word in 0900 ; FR0 to FP 0910 ; 0920 .MACRO @WRD2FP 0930 JSR IFP ;[D9AA] 0940 .ENDM 0950 ; 0960 ; 0970 ; 0980 ; MACRO: @FP2WRD 0990 ; 1000 ; FORM: @FP2WRD 1010 ; 1020 ; converts a FP number in FR0 1030 ; to a two byte word 1040 ; 1050 .MACRO @FP2WRD 1060 JSR FPI ;[D9D2] 1070 BCC @B1 1080 JMP FPERROR 1090 @B1 NOP 1100 .ENDM 1110 ; 1120 ; 1130 ; 1140 ; MACRO: @LODFR0 1150 ; 1160 ; FORM: @LODFR0 buffer 1170 ; 1180 ; loads FR0 with 10 byte ASCII 1190 ; number at buffer 1200 ; 1210 .MACRO @LODFR0 1220 LDA # <%1 1230 STA FLPTR 1240 LDA # >%1 1250 STA FLPTR+1 1260 JSR FLD0P ;[DD8D] 1270 .ENDM 1280 ; 1290 ; 1300 ; 1310 ; MACRO: @LODFR1 1320 ; 1330 ; FORM: @LODFR1 buffer 1340 ; 1350 ; loads FR1 with 10 byte ASCII 1360 ; number at buffer 1370 ; 1380 .MACRO @LODFR1 1390 LDA # <%1 1400 STA FLPTR 1410 LDA # >%1 1420 STA FLPTR+1 1430 JSR FLD1P ;[DD9C] 1440 .ENDM 1450 ; 1460 ; 1470 ; 1480 ; MACRO: @STFR0 1490 ; 1500 ; FORM: @STFR0 buffer 1510 ; 1520 ; stores number in FR0 to buffer 1530 ; 1540 .MACRO @STFR0 1550 LDA # <%1 1560 STA FLPTR 1570 LDA # >%1 1580 STA FLPTR+1 1590 JSR FSTOP ;[DDAB] 1600 .ENDM 1610 ; 1620 ; 1630 ; 1640 ; MACRO: @FR02FR1 1650 ; 1660 ; FORM: @FR02FR1 1670 ; 1680 ; moves FP number from FR0 to 1690 ; FR1 1700 ; 1710 .MACRO @FR02FR1 1720 JSR FMOVE ;[DDB6] 1730 .ENDM 1740 ; 1750 ; 1760 ; 1770 ; MACRO: @MATH 1780 ; 1790 ; FORM: @MATH op addr,buffer1,buffer2 [,buffer3] 1800 ; 1810 ; performs FP math function as 1820 ; called by other FP macros with 1830 ; result to buffer 3 if no 1840 ; buffer 3 is specified the 1850 ; result is stored in buffer 1 1860 ; 1870 .MACRO @MATH 1880 @A2FP %3 1890 @FR02FR1 1900 @A2FP %2 1910 JSR %1 ; FP operation addr 1920 BCC @B1 1930 JMP FPERROR 1940 @B1 @FP2A 1950 .IF %0<4 1960 @FP2MEM %2 1970 .ELSE 1980 @FP2MEM %4 1990 .ENDIF 2000 .ENDM 2010 ; 2020 ; 2030 ; 2040 ; MACRO: ADD 2050 ; 2060 ; FORM: ADD buffer1,buffer2 [,buffer3] 2070 ; 2080 ; adds buffers 1 and 2 2090 ; uses the macro @MATH 2100 ; see @MATH for details 2110 ; 2120 .MACRO ADD 2130 .IF %0=2 2140 @MATH FADD,%1,%2 2150 .ELSE 2160 @MATH FADD,%1,%2,%3 2170 .ENDIF 2180 .ENDM 2190 ; 2200 ; 2210 ; 2220 ; MACRO: SUB 2230 ; 2240 ; FORM: SUB (as in ADD) 2250 ; 2260 ; subtracts buffer2 from buffer1 2270 ; see @MATH for details 2280 ; 2290 .MACRO SUB 2300 .IF %0=2 2310 @MATH FSUB,%1,%2 2320 .ELSE 2330 @MATH FSUB,%1,%1,%3 2340 .ENDIF 2350 .ENDM 2360 ; 2370 ; 2380 ; 2390 ; MACRO: MUL 2400 ; 2410 ; FORM: MUL (as in ADD) 2420 ; 2430 ; multiplies buffer1 by buffer2 2440 ; see @MATH for details 2450 ; 2460 .MACRO MUL 2470 .IF %0=2 2480 @MATH FMUL,%1,%2 2490 .ELSE 2500 @MATH FMUL,%1,%1,%3 2510 .ENDIF 2520 .ENDM 2530 ; 2540 ; 2550 ; 2560 ; MACRO: DIV 2570 ; 2580 ; FORM: DIV (as in ADD) 2590 ; 2600 ; divides buffer1 by buffer2 2610 ; see @MATH for details 2620 ; 2630 .MACRO DIV 2640 .IF %0=2 2650 @MATH FDIV,%1,%2 2660 .ELSE 2670 @MATH FDIV,%1,%1,%3 2680 .ENDIF 2690 .ENDM 2700 ; 2710 ; 2720 ; 2730 ; MACRO: LOG 2740 ; 2750 ; FORM: LOG buffer1 [,buffer2] 2760 ; 2770 ; takes the natural logarithm 2780 ; of buffer1 and stores it in 2790 ; buffer2 if no buffer2 is 2800 ; specified then the result is 2810 ; put back in buffer1 2820 ; 2830 .MACRO LOG 2840 @A2FP %1 2850 JSR LOG ;[DECD] 2860 .IF %0=2 2870 @FP2MEM %2 2880 .ELSE 2890 @FP2MEM %1 2900 .ENDIF 2910 .ENDM 2920 ; 2930 ; 2940 ; 2950 ; MACRO: CLOG 2960 ; 2970 ; FORM: CLOG buffer1 [,buffer2] 2980 ; 2990 ; takes the base 10 logarithm 3000 ; of buffer1 as in LOG 3010 ; 3020 .MACRO CLOG 3030 @A2FP %1 3040 JSR LOG10 ;[DED1] 3050 .IF %0=2 3060 @FP2MEM %2 3070 .ELSE 3080 @FP2MEM %1 3090 .ENDIF 3100 .ENDM 3110 ; 3120 ; 3130 ; 3140 ; MACRO: LET 3150 ; 3160 ; FORM: LET label,string 3170 ; 3180 ; asigns a string or floating 3190 ; point number to a label 3200 ; FP numbers are up to 10 bytes 3210 ; either must be in quotes 3220 ; 3230 .MACRO LET 3240 SAVEPC =* 3250 *= %1 3260 .BYTE %2 3270 *= SAVEPC 3280 .ENDM 3290 ; 3300 ; 3310 ; ÿ