Home » CEEFAX disks » telesoftware6.adl » 15-04-88/B\OSB22
15-04-88/B\OSB22
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » CEEFAX disks » telesoftware6.adl |
Filename: | 15-04-88/B\OSB22 |
Read OK: | ✔ |
File size: | 2BBD bytes |
Load address: | 0800 |
Exec address: | 8023 |
Duplicates
There is 1 duplicate copy of this file in the archive:
- CEEFAX disks » telesoftware2.adl » OS\BITS/B\OSB22
- CEEFAX disks » telesoftware6.adl » 15-04-88/B\OSB22
File contents
10REM OSbits module B/osb22 20REM Floating Point Arithmetic - Addition and Subtraction 30REM Version 1.5 30.5.87 40 50*KEY1MO.3|M|NL.|M 60 70DIM code% &300 80 90PRINT '"Floating Point Addition and Subtraction"' 100INPUT "Enter the first number "fp1 110INPUT "Enter the second number "fp2 120PRINT 130 140FOR pass%=0 TO 2 STEP 2 150P%=code% 160 170[OPT pass% 180 190\ Transfer numbers from input_1 and 2 into 200\ workspace for addition 210 220JSR transfer_in 230 240JSR fp_add \ Addition subroutine 250 260\ Transfer result into 'result_add' 270 280LDX #5 290 300.transfer_out_loop 310 320LDA fpws_1-1, X 330STA result_add-1, X 340DEX 350BNE transfer_out_loop 360 370\ Transfer numbers from input_1 and 2 into 380\ workspace for subtraction 390 400JSR transfer_in 410 420JSR fp_sub \ Subtraction subroutine 430 440\ Transfer result into 'result_sub' 450 460LDX #5 470 480.transfer_out_loop2 490 500LDA fpws_1-1, X 510STA result_sub-1, X 520DEX 530BNE transfer_out_loop2 540 550RTS 560 570\ Reservation of workspace. Note bytes for sign of fp numbers 580\ and for overflow (oflow) during calculations. 590 600.input_1 OPT FNEQUF(fp1) 610.input_2 OPT FNEQUF(fp2) 620.fpws_1_sign OPT FNEQUB(0) 630.fpws_1_oflow OPT FNEQUB(0) 640.fpws_1 OPT FNEQUM(5,0) 650.fpws_2_sign OPT FNEQUB(0) 660.fpws_2_oflow OPT FNEQUB(0) 670.fpws_2 OPT FNEQUM(5,0) 680.result_add OPT FNEQUM(5,0) 690.result_sub OPT FNEQUM(5,0) 700 710.fp_add 720 730\ Adds together the numbers in fpws_1 and fpws_1 740\ and puts the result in fpws_1 750 760\ First allow for zeros in the workspace 770 780LDA fpws_2+1 790ORA fpws_2 \ Zero if exponent & top mantissa byte zero 800BEQ exit_addition \ If 2nd no is 0 result = 1st no 810 820LDA fpws_1+1 830ORA fpws_1 \ Zero if exponent & top mantissa byte zero 840BNE dont_transfer \ If only 1st no is zero answer is 2nd no 850 860LDX #5 870 880.zero_compensation_loop \ transfer second no and exit addition 890 900LDA fpws_2-1, X 910STA fpws_1-1, X 920DEX 930BNE zero_compensation_loop 940JMP exit_addition 950 960.dont_transfer 970 980JSR move_sign_bit \ Move sign and restore top bit 990 1000JSR equate_exponents \ Denormalise smaller number 1010 1020JSR neg_convert \ Convert neg nos to 2's complement 1030 1040JSR add_mantissae 1050 1060JSR neg_convert_back \ Convert 2's complement back to neg 1070 1080\ Trap a zero result or renormalising routine will loop indefinately 1090 1100LDA fpws_1_oflow 1110ORA fpws_1+1 1120ORA fpws_1+2 1130ORA fpws_1+3 1140ORA fpws_1+4 \ ORing bytes together gives 0 if all are 0 1150 1160BEQ zero_result \ Put zero into workspace then exit 1170 1180JSR renormalise 1190 1200JSR replace_sign_bit \ Replace top bit with sign 1210 1220.exit_addition 1230 1240RTS 1250 1260.zero_result 1270 1280LDA #0 1290STA fpws_1 \ Clear exponent of a zero number 1300 1310RTS 1320 1330.fp_sub 1340 1350\ Subtracts the number in fpws_2 from fpws_1 1360\ and puts the result in fpws_1 1370 1380\ First allow for zeros in the workspace 1390 1400LDA fpws_2+1 1410ORA fpws_2 \ Zero if exponent & top mantissa byte zero 1420BEQ exit_subtraction \ If 2nd no is 0 result = 1st no 1430 1440LDA fpws_1+1 1450ORA fpws_1 \ Zero if exponent & top mantissa byte zero 1460BNE dont_transfer_sub \ If only 1st no is zero answer is -2nd no 1470 1480LDX #5 1490 1500.zero_compensation_loop2 \ transfer second no and exit subtraction 1510 1520LDA fpws_2-1, X 1530STA fpws_1-1, X 1540DEX 1550BNE zero_compensation_loop2 1560LDA fpws_1+1 1570EOR #&80 1580STA fpws_1+1 \ Change sign of second number -> result 1590JMP exit_subtraction 1600 1610.dont_transfer_sub 1620 1630JSR move_sign_bit \ Move sign and restore top bit 1640 1650JSR equate_exponents \ Denormalise smaller number 1660 1670JSR neg_convert \ Convert neg nos to 2's complement 1680 1690JSR subtract_mantissae 1700 1710JSR neg_convert_back \ Convert 2's complement back to neg 1720 1730\ Trap a zero result or renormalising routine will loop indefinately 1740 1750LDA fpws_1_oflow 1760ORA fpws_1+1 1770ORA fpws_1+2 1780ORA fpws_1+3 1790ORA fpws_1+4 \ ORing bytes together gives 0 if all are 0 1800 1810BEQ zero_result \ Put zero into workspace then exit 1820 1830JSR renormalise 1840 1850JSR replace_sign_bit \ Replace top bit with sign 1860 1870.exit_subtraction 1880 1890RTS 1900 1910.transfer_in 1920 1930\ This subroutine takes the numbers in input_1 and 1940\ input_2 and puts them in fpws_1 and fpws_2 1950 1960LDX #5 1970 1980.transfer_in_loop 1990 2000LDA input_1-1, X 2010STA fpws_1-1, X 2020LDA input_2-1, X 2030STA fpws_2-1, X 2040DEX 2050BNE transfer_in_loop 2060 2070LDA #0 2080STA fpws_1_oflow 2090STA fpws_2_oflow 2100 2110RTS 2120 2130.move_sign_bit 2140 2150\ This routine transfers the sign bit from the top of the mantissae 2160\ and puts it into a sign byte - ANDing to leave top bit only 2170\ and then restores the top bit of the mantissae 2180 2190LDA fpws_1+1 2200AND #&80 2210STA fpws_1_sign \ fpws_1_sign is -ve if number was -ve 2220LDA #&80 2230ORA fpws_1+1 2240STA fpws_1+1 \ Restores the top bit of the number 2250 2260LDA fpws_2+1 2270AND #&80 2280STA fpws_2_sign \ fpws_2_sign is -ve if number was -ve 2290LDA #&80 2300ORA fpws_2+1 2310STA fpws_2+1 \ Restores the top bit of the number 2320 2330RTS 2340 2350.equate_exponents 2360 2370\ This routine modifies the smaller number so that the exponents 2380\ are the same 2390 2400SEC 2410LDA fpws_1 2420SBC fpws_2 \ Find which exponent is greater 2430BEQ exponents_equal 2440BPL ws1_is_greater 2450 2460.ws2_is_greater 2470 2480INC fpws_1 \ Increase the lesser exponent 2490LSR fpws_1+1 \ Shift mantissa right to compensate 2500ROR fpws_1+2 2510ROR fpws_1+3 2520ROR fpws_1+4 2530 2540LDA fpws_2 2550CMP fpws_1 2560BNE ws2_is_greater \ Finish when exponents are equal 2570RTS 2580 2590.ws1_is_greater 2600 2610INC fpws_2 \ Increase lesser exponent 2620LSR fpws_2+1 \ Shift mantissa right to compensate 2630ROR fpws_2+2 2640ROR fpws_2+3 2650ROR fpws_2+4 2660 2670LDA fpws_1 2680CMP fpws_2 2690BNE ws1_is_greater \ Finish when exponents are equal 2700 2710.exponents_equal 2720 2730RTS 2740 2750.neg_convert 2760 2770\ Because the fp format is not 2's complement we have to convert 2780\ negative numbers to 2's complement before calculating with them 2790\ for addition and subtraction. 2800 2810LDA fpws_2_sign 2820BPL fp2_pos 2830 2840SEC \ Subtract from zero 2850LDA #0 2860SBC fpws_2+4 2870STA fpws_2+4 2880LDA #0 2890SBC fpws_2+3 2900STA fpws_2+3 2910LDA #0 2920SBC fpws_2+2 2930STA fpws_2+2 2940LDA #0 2950SBC fpws_2+1 2960STA fpws_2+1 2970LDA #0 2980SBC fpws_2_oflow \ Don't forget to include the overflow 2990STA fpws_2_oflow 3000 3010.fp2_pos 3020 3030LDA fpws_1_sign 3040BPL fp1_pos 3050 3060.convert_sign_fpws1 3070 3080SEC \ Subtract from zero 3090LDA #0 3100SBC fpws_1+4 3110STA fpws_1+4 3120LDA #0 3130SBC fpws_1+3 3140STA fpws_1+3 3150LDA #0 3160SBC fpws_1+2 3170STA fpws_1+2 3180LDA #0 3190SBC fpws_1+1 3200STA fpws_1+1 3210LDA #0 3220SBC fpws_1_oflow \ Overflow 3230STA fpws_1_oflow 3240 3250. fp1_pos 3260 3270RTS 3280 3290.add_mantissae 3300 3310\ This routine adds the mantissae with overflows 3320 3330CLC 3340LDA fpws_1+4 \ Standard add but with bytes reversed 3350ADC fpws_2+4 3360STA fpws_1+4 3370LDA fpws_1+3 3380ADC fpws_2+3 3390STA fpws_1+3 3400LDA fpws_1+2 3410ADC fpws_2+2 3420STA fpws_1+2 3430LDA fpws_1+1 3440ADC fpws_2+1 3450STA fpws_1+1 3460LDA fpws_1_oflow 3470ADC fpws_2_oflow 3480STA fpws_1_oflow 3490 3500RTS 3510 3520.subtract_mantissae 3530 3540\ This routine subtracts the mantissae with overflows 3550 3560SEC 3570LDA fpws_1+4 \ Standard subtract but with bytes reversed 3580SBC fpws_2+4 3590STA fpws_1+4 3600LDA fpws_1+3 3610SBC fpws_2+3 3620STA fpws_1+3 3630LDA fpws_1+2 3640SBC fpws_2+2 3650STA fpws_1+2 3660LDA fpws_1+1 3670SBC fpws_2+1 3680STA fpws_1+1 3690LDA fpws_1_oflow 3700SBC fpws_2_oflow 3710STA fpws_1_oflow 3720 3730RTS 3740 3750.neg_convert_back 3760 3770\ This routine converts any 2's complement result into fp format 3780 3790LDA fpws_1_oflow 3800BPL res_pos 3810 3820JSR convert_sign_fpws1 3830LDA #&80 3840STA fpws_1_sign 3850RTS 3860 3870.res_pos 3880 3890LDA #0 3900STA fpws_1_sign 3910 3920RTS 3930 3940.renormalise 3950 3960\ This routine modifies the mantissa and exponent of the result 3970\ To produce a normalised format number. 3980 3990LDA fpws_1_oflow 4000BNE shift_right \ If overflow is >0 we shift mantissa right 4010 4020LDA fpws_1+1 \ Top byte of mantissa is shifted left 4030BMI normalised \ until top bit is set (i.e. -ve) 4040 4050.shift_left_loop 4060 4070DEC fpws_1 \ Decrease the exponent 4080ASL fpws_1+4 \ Shift mantissa left to compensate 4090ROL fpws_1+3 4100ROL fpws_1+2 4110ROL fpws_1+1 4120 4130BPL shift_left_loop 4140 4150RTS \ Number renormalised 4160 4170.shift_right 4180 4190INC fpws_1 \ Increase the exponent 4200BEQ too_big \ If exp is zero we have overflow 4210LSR fpws_1_oflow 4220ROR fpws_1+1 \ Shift mantissa right to compensate 4230ROR fpws_1+2 4240ROR fpws_1+3 4250ROR fpws_1+4 4260 4270LDA fpws_1_oflow 4280BNE shift_right 4290 4300.normalised 4310 4320RTS 4330 4340.replace_sign_bit 4350 4360CLC 4370LDA fpws_1+1 4380AND #&7F 4390ADC fpws_1_sign 4400STA fpws_1+1 \ If +ve clear top bit of mantissa 4410 4420RTS 4430 4440.too_big 4450 4460\ This is an error condition - number 20 4470 4480BRK 4490OPT FNEQUB(20) 4500OPT FNEQUS("Result of multiplication is too big") 4510OPT FNEQUB(0) 4520 4530] 4540NEXT 4550 4560CALL code% 4570 4580PRINT"Results:"' 4590PRINT "Addition (code) is ";FNfp(result_add) 4600PRINT "Addition (BASIC) is ";fp1+fp2 4610 4620PRINT "Subtraction (code) is ";FNfp(result_sub) 4630PRINT "Subtraction (BASIC) is ";fp1-fp2 4640 4650END 4660 4670**** EQUate a Byte **** 4680DEF FNEQUB(N%) 4690?P%=N% MOD 256 4700IF (pass% AND 3) = 3 THEN PRINT ~?P% 4710P%=P%+1 4720=pass% 4730 4740**** EQUate a String **** 4750DEF FNEQUS(N$) 4760LOCAL N% 4770WIDTH 40 4780FOR N%=1 TO LEN(N$) 4790K%=ASC(MID$(N$,N%,1)) 4800P%?(N%-1)=K% 4810IF (pass% AND 3) = 3 THEN PRINT ~P%?(N%-1); 4820NEXT 4830IF (pass% AND 3) = 3 THEN PRINT 4840P%=P%+LEN(N$) 4850WIDTH 0 4860=pass% 4870 4880**** EQUate a section of Memory **** 4890DEF FNEQUM(number%,byte%) 4900LOCAL N% 4910WIDTH 40 4920FOR N%=0 TO number%-1 4930P%?N%=byte% 4940IF (pass% AND 3) = 3 THEN PRINT ~P%?N%; 4950NEXT 4960IF (pass% AND 3) = 3 THEN PRINT 4970P%=P%+number% 4980WIDTH 0 4990=pass% 5000 5010**** EQUate a floating point number **** 5020We use the variable ` 5030to gain access to BASIC's fp conversion 5040routines. No other variables beginning 5050with ` can be defined. 5060DEF FNEQUF(`) 5070LOCAL M%, N% 5080WIDTH 40 5090M% = 3+(!&4C0 AND &FFFF) 5100FOR N%=0 TO 4 5110P%?N%=M%?N% 5120IF (pass% AND 3) = 3 THEN PRINT ~P%?N%; 5130NEXT 5140IF (pass% AND 3) = 3 THEN PRINT 5150P%=P%+5 5160WIDTH 0 5170=pass% 5180 5190**** Reverse FP **** 5200Puts fp number from memory 5210into variable ` (POUND) 5220DEF FNfp(mem%) 5230LOCAL M%, N% 5240`=0 5250M% = 3+(!&4C0 AND &FFFF) 5260FOR N%=0 TO 4 5270M%?N%=mem%?N% 5280NEXT 5290=`
� OSbits module B/osb22 ;� Floating Point Arithmetic - Addition and Subtraction � Version 1.5 30.5.87 ( 2*KEY1MO.3|M|NL.|M < F� code% &300 P Z1� '"Floating Point Addition and Subtraction"' d"� "Enter the first number "fp1 n#� "Enter the second number "fp2 x� � �� pass%=0 � 2 � 2 �P%=code% � �[OPT pass% � �/\ Transfer numbers from input_1 and 2 into �\ workspace for addition � �JSR transfer_in � �6JSR fp_add \ Addition subroutine � (\ Transfer result into 'result_add' LDX #5 " ,.transfer_out_loop 6 @LDA fpws_1-1, X JSTA result_add-1, X TDEX ^BNE transfer_out_loop h r/\ Transfer numbers from input_1 and 2 into | \ workspace for subtraction � �JSR transfer_in � �9JSR fp_sub \ Subtraction subroutine � �(\ Transfer result into 'result_sub' � � LDX #5 � �.transfer_out_loop2 � �LDA fpws_1-1, X �STA result_sub-1, X DEX BNE transfer_out_loop2 &RTS 0 :C\ Reservation of workspace. Note bytes for sign of fp numbers D4\ and for overflow (oflow) during calculations. N X .input_1 OPT �EQUF(fp1) b .input_2 OPT �EQUF(fp2) l.fpws_1_sign OPT �EQUB(0) v.fpws_1_oflow OPT �EQUB(0) � .fpws_1 OPT �EQUM(5,0) �.fpws_2_sign OPT �EQUB(0) �.fpws_2_oflow OPT �EQUB(0) � .fpws_2 OPT �EQUM(5,0) � .result_add OPT �EQUM(5,0) � .result_sub OPT �EQUM(5,0) � �.fp_add � �5\ Adds together the numbers in fpws_1 and fpws_1 �$\ and puts the result in fpws_1 � �-\ First allow for zeros in the workspace LDA fpws_2+1 J�A fpws_2 \ Zero if exponent & top mantissa byte zero ABEQ exit_addition \ If 2nd no is 0 result = 1st no * 4LDA fpws_1+1 >J�A fpws_1 \ Zero if exponent & top mantissa byte zero HIBNE dont_transfer \ If only 1st no is zero answer is 2nd no R \ LDX #5 f pG.zero_compensation_loop \ transfer second no and exit addition z �LDA fpws_2-1, X �STA fpws_1-1, X �DEX �BNE zero_compensation_loop �JMP exit_addition � �.dont_transfer � �?JSR move_sign_bit \ Move sign and restore top bit � �<JSR equate_exponents \ Denormalise smaller number � �CJSR neg_convert \ Convert neg nos to 2's complement JSR add_mantissae $DJSR neg_convert_back \ Convert 2's complement back to neg . 8I\ Trap a zero result or renormalising routine will loop indefinately B LLDA fpws_1_oflow V�A fpws_1+1 `�A fpws_1+2 j�A fpws_1+3 tI�A fpws_1+4 \ �ing bytes together gives 0 if all are 0 ~ �CBEQ zero_result \ Put zero into workspace then exit � �JSR renormalise � �;JSR replace_sign_bit \ Replace top bit with sign � �.exit_addition � �RTS � �.zero_result � LDA #0 ASTA fpws_1 \ Clear exponent of a zero number RTS ( 2.fp_sub < F1\ Subtracts the number in fpws_2 from fpws_1 P$\ and puts the result in fpws_1 Z d-\ First allow for zeros in the workspace n xLDA fpws_2+1 �J�A fpws_2 \ Zero if exponent & top mantissa byte zero �ABEQ exit_subtraction \ If 2nd no is 0 result = 1st no � �LDA fpws_1+1 �J�A fpws_1 \ Zero if exponent & top mantissa byte zero �JBNE dont_transfer_sub \ If only 1st no is zero answer is -2nd no � � LDX #5 � �J.zero_compensation_loop2 \ transfer second no and exit subtraction � �LDA fpws_2-1, X �STA fpws_1-1, X DEX BNE zero_compensation_loop2 LDA fpws_1+1 " � #&80 ,ISTA fpws_1+1 \ Change sign of second number -> result 6JMP exit_subtraction @ J.dont_transfer_sub T ^?JSR move_sign_bit \ Move sign and restore top bit h r<JSR equate_exponents \ Denormalise smaller number | �CJSR neg_convert \ Convert neg nos to 2's complement � �JSR subtract_mantissae � �DJSR neg_convert_back \ Convert 2's complement back to neg � �I\ Trap a zero result or renormalising routine will loop indefinately � �LDA fpws_1_oflow ��A fpws_1+1 ��A fpws_1+2 ��A fpws_1+3 �I�A fpws_1+4 \ �ing bytes together gives 0 if all are 0 CBEQ zero_result \ Put zero into workspace then exit &JSR renormalise 0 :;JSR replace_sign_bit \ Replace top bit with sign D N.exit_subtraction X bRTS l v.transfer_in � �7\ This subroutine takes the numbers in input_1 and �1\ input_2 and puts them in fpws_1 and fpws_2 � � LDX #5 � �.transfer_in_loop � �LDA input_1-1, X �STA fpws_1-1, X �LDA input_2-1, X �STA fpws_2-1, X �DEX BNE transfer_in_loop LDA #0 STA fpws_1_oflow *STA fpws_2_oflow 4 >RTS H R.move_sign_bit \ fH\ This routine transfers the sign bit from the top of the mantissae p@\ and puts it into a sign byte - �ing to leave top bit only z5\ and then restores the top bit of the mantissae � �LDA fpws_1+1 � � #&80 �FSTA fpws_1_sign \ fpws_1_sign is -ve if number was -ve �LDA #&80 ��A fpws_1+1 �DSTA fpws_1+1 \ Restores the top bit of the number � �LDA fpws_2+1 � � #&80 �FSTA fpws_2_sign \ fpws_2_sign is -ve if number was -ve �LDA #&80 ��A fpws_2+1 DSTA fpws_2+1 \ Restores the top bit of the number RTS $ ..equate_exponents 8 BE\ This routine modifies the smaller number so that the exponents L\ are the same V `SEC jLDA fpws_1 t@SBC fpws_2 \ Find which exponent is greater ~BEQ exponents_equal �BPL ws1_is_greater � �.ws2_is_greater � �>INC fpws_1 \ Increase the lesser exponent �DLSR fpws_1+1 \ Shift mantissa right to compensate �ROR fpws_1+2 �ROR fpws_1+3 �ROR fpws_1+4 � �LDA fpws_2 �CMP fpws_1 ABNE ws2_is_greater \ Finish when exponents are equal RTS .ws1_is_greater ( 2:INC fpws_2 \ Increase lesser exponent <DLSR fpws_2+1 \ Shift mantissa right to compensate FROR fpws_2+2 PROR fpws_2+3 ZROR fpws_2+4 d nLDA fpws_1 xCMP fpws_2 �@BNE ws1_is_greater \ Finish when exponents are equal � �.exponents_equal � �RTS � �.neg_convert � �E\ Because the fp format is not 2's complement we have to convert �F\ negative numbers to 2's complement before calculating with them �$\ for addition and subtraction. � �LDA fpws_2_sign BPL fp2_pos 4SEC \ Subtract from zero " LDA #0 ,SBC fpws_2+4 6STA fpws_2+4 @ LDA #0 JSBC fpws_2+3 TSTA fpws_2+3 ^ LDA #0 hSBC fpws_2+2 rSTA fpws_2+2 | LDA #0 �SBC fpws_2+1 �STA fpws_2+1 � LDA #0 �FSBC fpws_2_oflow \ Don't forget to include the overflow �STA fpws_2_oflow � �.fp2_pos � �LDA fpws_1_sign �BPL fp1_pos � �.convert_sign_fpws1 � 4SEC \ Subtract from zero LDA #0 SBC fpws_1+4 &STA fpws_1+4 0 LDA #0 :SBC fpws_1+3 DSTA fpws_1+3 N LDA #0 XSBC fpws_1+2 bSTA fpws_1+2 l LDA #0 vSBC fpws_1+1 �STA fpws_1+1 � LDA #0 �*SBC fpws_1_oflow \ Overflow �STA fpws_1_oflow � � . fp1_pos � �RTS � �.add_mantissae � �5\ This routine adds the mantissae with overflows � CLC FLDA fpws_1+4 \ Standard add but with bytes reversed ADC fpws_2+4 STA fpws_1+4 *LDA fpws_1+3 4ADC fpws_2+3 >STA fpws_1+3 HLDA fpws_1+2 RADC fpws_2+2 \STA fpws_1+2 fLDA fpws_1+1 pADC fpws_2+1 zSTA fpws_1+1 �LDA fpws_1_oflow �ADC fpws_2_oflow �STA fpws_1_oflow � �RTS � �.subtract_mantissae � �:\ This routine subtracts the mantissae with overflows � �SEC �KLDA fpws_1+4 \ Standard subtract but with bytes reversed �SBC fpws_2+4 STA fpws_1+4 LDA fpws_1+3 SBC fpws_2+3 $STA fpws_1+3 .LDA fpws_1+2 8SBC fpws_2+2 BSTA fpws_1+2 LLDA fpws_1+1 VSBC fpws_2+1 `STA fpws_1+1 jLDA fpws_1_oflow tSBC fpws_2_oflow ~STA fpws_1_oflow � �RTS � �.neg_convert_back � �E\ This routine converts any 2's complement result into fp format � �LDA fpws_1_oflow �BPL res_pos � �JSR convert_sign_fpws1 �LDA #&80 STA fpws_1_sign RTS .res_pos ( 2 LDA #0 <STA fpws_1_sign F PRTS Z d.renormalise n xC\ This routine modifies the mantissa and exponent of the result �,\ To produce a normalised format number. � �LDA fpws_1_oflow �KBNE shift_right \ If overflow is >0 we shift mantissa right � �FLDA fpws_1+1 \ Top byte of mantissa is shifted left �ABMI normalised \ until top bit is set (i.e. -ve) � �.shift_left_loop � �7DEC fpws_1 \ Decrease the exponent �CASL fpws_1+4 \ Shift mantissa left to compensate �ROL fpws_1+3 ROL fpws_1+2 ROL fpws_1+1 "BPL shift_left_loop , 65RTS \ Number renormalised @ J.shift_right T ^7INC fpws_1 \ Increase the exponent hABEQ too_big \ If exp is zero we have overflow rLSR fpws_1_oflow |DROR fpws_1+1 \ Shift mantissa right to compensate �ROR fpws_1+2 �ROR fpws_1+3 �ROR fpws_1+4 � �LDA fpws_1_oflow �BNE shift_right � �.normalised � �RTS � �.replace_sign_bit � CLC LDA fpws_1+1 � #&7F &ADC fpws_1_sign 0BSTA fpws_1+1 \ If +ve clear top bit of mantissa : DRTS N X.too_big b l-\ This is an error condition - number 20 v �BRK �OPT �EQUB(20) �5OPT �EQUS("Result of multiplication is too big") �OPT �EQUB(0) � �] �� � �� code% � ��"Results:"' �,� "Addition (code) is ";�fp(result_add) �$� "Addition (BASIC) is ";fp1+fp2 /� "Subtraction (code) is ";�fp(result_sub) '� "Subtraction (BASIC) is ";fp1-fp2 *� 4 >**** EQUate a Byte **** H� �EQUB(N%) R?P%=N% � 256 \� (pass% � 3) = 3 � � ~?P% fP%=P%+1 p =pass% z �**** EQUate a String **** �� �EQUS(N$) �� N% �� 40 �� N%=1 � �(N$) �K%=�(�N$,N%,1)) �P%?(N%-1)=K% �%� (pass% � 3) = 3 � � ~P%?(N%-1); �� �� (pass% � 3) = 3 � � �P%=P%+�(N$) �� 0 � =pass% (**** EQUate a section of Memory **** � �EQUM(number%,byte%) $� N% .� 40 8� N%=0 � number%-1 BP%?N%=byte% L!� (pass% � 3) = 3 � � ~P%?N%; V� `� (pass% � 3) = 3 � � jP%=P%+number% t� 0 ~ =pass% � �,**** EQUate a floating point number **** �We use the variable ` �+to gain access to BASIC's fp conversion �*routines. No other variables beginning �with ` can be defined. �� �EQUF(`) �� M%, N% �� 40 �M% = 3+(!&4C0 � &FFFF) �� N%=0 � 4 �P%?N%=M%?N% !� (pass% � 3) = 3 � � ~P%?N%; � � (pass% � 3) = 3 � � P%=P%+5 (� 0 2 =pass% < F**** Reverse FP **** PPuts fp number from memory Zinto variable ` (POUND) d� �fp(mem%) n� M%, N% x`=0 �M% = 3+(!&4C0 � &FFFF) �� N%=0 � 4 �M%?N%=mem%?N% �� �=` �
00000000 0d 00 0a 1c f4 20 20 4f 53 62 69 74 73 20 6d 6f |..... OSbits mo| 00000010 64 75 6c 65 20 42 2f 6f 73 62 32 32 0d 00 14 3b |dule B/osb22...;| 00000020 f4 20 20 46 6c 6f 61 74 69 6e 67 20 50 6f 69 6e |. Floating Poin| 00000030 74 20 41 72 69 74 68 6d 65 74 69 63 20 2d 20 41 |t Arithmetic - A| 00000040 64 64 69 74 69 6f 6e 20 61 6e 64 20 53 75 62 74 |ddition and Subt| 00000050 72 61 63 74 69 6f 6e 0d 00 1e 1a f4 20 20 56 65 |raction..... Ve| 00000060 72 73 69 6f 6e 20 31 2e 35 20 33 30 2e 35 2e 38 |rsion 1.5 30.5.8| 00000070 37 0d 00 28 05 20 0d 00 32 15 2a 4b 45 59 31 4d |7..(. ..2.*KEY1M| 00000080 4f 2e 33 7c 4d 7c 4e 4c 2e 7c 4d 0d 00 3c 05 20 |O.3|M|NL.|M..<. | 00000090 0d 00 46 10 de 20 63 6f 64 65 25 20 26 33 30 30 |..F.. code% &300| 000000a0 0d 00 50 05 20 0d 00 5a 31 f1 20 27 22 46 6c 6f |..P. ..Z1. '"Flo| 000000b0 61 74 69 6e 67 20 50 6f 69 6e 74 20 41 64 64 69 |ating Point Addi| 000000c0 74 69 6f 6e 20 61 6e 64 20 53 75 62 74 72 61 63 |tion and Subtrac| 000000d0 74 69 6f 6e 22 27 0d 00 64 22 e8 20 22 45 6e 74 |tion"'..d". "Ent| 000000e0 65 72 20 74 68 65 20 66 69 72 73 74 20 6e 75 6d |er the first num| 000000f0 62 65 72 20 22 66 70 31 0d 00 6e 23 e8 20 22 45 |ber "fp1..n#. "E| 00000100 6e 74 65 72 20 74 68 65 20 73 65 63 6f 6e 64 20 |nter the second | 00000110 6e 75 6d 62 65 72 20 22 66 70 32 0d 00 78 05 f1 |number "fp2..x..| 00000120 0d 00 82 05 20 0d 00 8c 15 e3 20 70 61 73 73 25 |.... ..... pass%| 00000130 3d 30 20 b8 20 32 20 88 20 32 0d 00 96 0c 50 25 |=0 . 2 . 2....P%| 00000140 3d 63 6f 64 65 25 0d 00 a0 05 20 0d 00 aa 0e 5b |=code%.... ....[| 00000150 4f 50 54 20 70 61 73 73 25 0d 00 b4 05 20 0d 00 |OPT pass%.... ..| 00000160 be 2f 5c 20 20 54 72 61 6e 73 66 65 72 20 6e 75 |./\ Transfer nu| 00000170 6d 62 65 72 73 20 66 72 6f 6d 20 69 6e 70 75 74 |mbers from input| 00000180 5f 31 20 61 6e 64 20 32 20 69 6e 74 6f 0d 00 c8 |_1 and 2 into...| 00000190 1d 5c 20 20 77 6f 72 6b 73 70 61 63 65 20 66 6f |.\ workspace fo| 000001a0 72 20 61 64 64 69 74 69 6f 6e 0d 00 d2 05 20 0d |r addition.... .| 000001b0 00 dc 13 4a 53 52 20 74 72 61 6e 73 66 65 72 5f |...JSR transfer_| 000001c0 69 6e 0d 00 e6 05 20 0d 00 f0 36 4a 53 52 20 66 |in.... ...6JSR f| 000001d0 70 5f 61 64 64 20 20 20 20 20 20 20 20 20 20 20 |p_add | 000001e0 20 20 20 20 20 20 20 20 5c 20 41 64 64 69 74 69 | \ Additi| 000001f0 6f 6e 20 73 75 62 72 6f 75 74 69 6e 65 0d 00 fa |on subroutine...| 00000200 05 20 0d 01 04 28 5c 20 20 54 72 61 6e 73 66 65 |. ...(\ Transfe| 00000210 72 20 72 65 73 75 6c 74 20 69 6e 74 6f 20 27 72 |r result into 'r| 00000220 65 73 75 6c 74 5f 61 64 64 27 0d 01 0e 05 20 0d |esult_add'.... .| 00000230 01 18 0a 4c 44 58 20 23 35 0d 01 22 05 20 0d 01 |...LDX #5..". ..| 00000240 2c 16 2e 74 72 61 6e 73 66 65 72 5f 6f 75 74 5f |,..transfer_out_| 00000250 6c 6f 6f 70 0d 01 36 05 20 0d 01 40 13 4c 44 41 |loop..6. ..@.LDA| 00000260 20 66 70 77 73 5f 31 2d 31 2c 20 58 0d 01 4a 17 | fpws_1-1, X..J.| 00000270 53 54 41 20 72 65 73 75 6c 74 5f 61 64 64 2d 31 |STA result_add-1| 00000280 2c 20 58 0d 01 54 07 44 45 58 0d 01 5e 1a 42 4e |, X..T.DEX..^.BN| 00000290 45 20 74 72 61 6e 73 66 65 72 5f 6f 75 74 5f 6c |E transfer_out_l| 000002a0 6f 6f 70 20 0d 01 68 05 20 0d 01 72 2f 5c 20 20 |oop ..h. ..r/\ | 000002b0 54 72 61 6e 73 66 65 72 20 6e 75 6d 62 65 72 73 |Transfer numbers| 000002c0 20 66 72 6f 6d 20 69 6e 70 75 74 5f 31 20 61 6e | from input_1 an| 000002d0 64 20 32 20 69 6e 74 6f 0d 01 7c 20 5c 20 20 77 |d 2 into..| \ w| 000002e0 6f 72 6b 73 70 61 63 65 20 66 6f 72 20 73 75 62 |orkspace for sub| 000002f0 74 72 61 63 74 69 6f 6e 0d 01 86 05 20 0d 01 90 |traction.... ...| 00000300 13 4a 53 52 20 74 72 61 6e 73 66 65 72 5f 69 6e |.JSR transfer_in| 00000310 0d 01 9a 05 20 0d 01 a4 39 4a 53 52 20 66 70 5f |.... ...9JSR fp_| 00000320 73 75 62 20 20 20 20 20 20 20 20 20 20 20 20 20 |sub | 00000330 20 20 20 20 20 20 5c 20 53 75 62 74 72 61 63 74 | \ Subtract| 00000340 69 6f 6e 20 73 75 62 72 6f 75 74 69 6e 65 0d 01 |ion subroutine..| 00000350 ae 05 20 0d 01 b8 28 5c 20 20 54 72 61 6e 73 66 |.. ...(\ Transf| 00000360 65 72 20 72 65 73 75 6c 74 20 69 6e 74 6f 20 27 |er result into '| 00000370 72 65 73 75 6c 74 5f 73 75 62 27 0d 01 c2 05 20 |result_sub'.... | 00000380 0d 01 cc 0a 4c 44 58 20 23 35 0d 01 d6 05 20 0d |....LDX #5.... .| 00000390 01 e0 17 2e 74 72 61 6e 73 66 65 72 5f 6f 75 74 |....transfer_out| 000003a0 5f 6c 6f 6f 70 32 0d 01 ea 05 20 0d 01 f4 13 4c |_loop2.... ....L| 000003b0 44 41 20 66 70 77 73 5f 31 2d 31 2c 20 58 0d 01 |DA fpws_1-1, X..| 000003c0 fe 17 53 54 41 20 72 65 73 75 6c 74 5f 73 75 62 |..STA result_sub| 000003d0 2d 31 2c 20 58 0d 02 08 07 44 45 58 0d 02 12 1a |-1, X....DEX....| 000003e0 42 4e 45 20 74 72 61 6e 73 66 65 72 5f 6f 75 74 |BNE transfer_out| 000003f0 5f 6c 6f 6f 70 32 0d 02 1c 05 20 0d 02 26 07 52 |_loop2.... ..&.R| 00000400 54 53 0d 02 30 05 20 0d 02 3a 43 5c 20 20 52 65 |TS..0. ..:C\ Re| 00000410 73 65 72 76 61 74 69 6f 6e 20 6f 66 20 77 6f 72 |servation of wor| 00000420 6b 73 70 61 63 65 2e 20 20 4e 6f 74 65 20 62 79 |kspace. Note by| 00000430 74 65 73 20 66 6f 72 20 73 69 67 6e 20 6f 66 20 |tes for sign of | 00000440 66 70 20 6e 75 6d 62 65 72 73 0d 02 44 34 5c 20 |fp numbers..D4\ | 00000450 20 61 6e 64 20 66 6f 72 20 6f 76 65 72 66 6c 6f | and for overflo| 00000460 77 20 28 6f 66 6c 6f 77 29 20 64 75 72 69 6e 67 |w (oflow) during| 00000470 20 63 61 6c 63 75 6c 61 74 69 6f 6e 73 2e 0d 02 | calculations...| 00000480 4e 05 20 0d 02 58 20 2e 69 6e 70 75 74 5f 31 20 |N. ..X .input_1 | 00000490 20 20 20 20 20 4f 50 54 20 a4 45 51 55 46 28 66 | OPT .EQUF(f| 000004a0 70 31 29 0d 02 62 20 2e 69 6e 70 75 74 5f 32 20 |p1)..b .input_2 | 000004b0 20 20 20 20 20 4f 50 54 20 a4 45 51 55 46 28 66 | OPT .EQUF(f| 000004c0 70 32 29 0d 02 6c 1e 2e 66 70 77 73 5f 31 5f 73 |p2)..l..fpws_1_s| 000004d0 69 67 6e 20 20 4f 50 54 20 a4 45 51 55 42 28 30 |ign OPT .EQUB(0| 000004e0 29 0d 02 76 1e 2e 66 70 77 73 5f 31 5f 6f 66 6c |)..v..fpws_1_ofl| 000004f0 6f 77 20 4f 50 54 20 a4 45 51 55 42 28 30 29 0d |ow OPT .EQUB(0).| 00000500 02 80 20 2e 66 70 77 73 5f 31 20 20 20 20 20 20 |.. .fpws_1 | 00000510 20 4f 50 54 20 a4 45 51 55 4d 28 35 2c 30 29 0d | OPT .EQUM(5,0).| 00000520 02 8a 1e 2e 66 70 77 73 5f 32 5f 73 69 67 6e 20 |....fpws_2_sign | 00000530 20 4f 50 54 20 a4 45 51 55 42 28 30 29 0d 02 94 | OPT .EQUB(0)...| 00000540 1e 2e 66 70 77 73 5f 32 5f 6f 66 6c 6f 77 20 4f |..fpws_2_oflow O| 00000550 50 54 20 a4 45 51 55 42 28 30 29 0d 02 9e 20 2e |PT .EQUB(0)... .| 00000560 66 70 77 73 5f 32 20 20 20 20 20 20 20 4f 50 54 |fpws_2 OPT| 00000570 20 a4 45 51 55 4d 28 35 2c 30 29 0d 02 a8 20 2e | .EQUM(5,0)... .| 00000580 72 65 73 75 6c 74 5f 61 64 64 20 20 20 4f 50 54 |result_add OPT| 00000590 20 a4 45 51 55 4d 28 35 2c 30 29 0d 02 b2 20 2e | .EQUM(5,0)... .| 000005a0 72 65 73 75 6c 74 5f 73 75 62 20 20 20 4f 50 54 |result_sub OPT| 000005b0 20 a4 45 51 55 4d 28 35 2c 30 29 0d 02 bc 05 20 | .EQUM(5,0).... | 000005c0 0d 02 c6 0b 2e 66 70 5f 61 64 64 0d 02 d0 06 20 |.....fp_add.... | 000005d0 20 0d 02 da 35 5c 20 20 41 64 64 73 20 74 6f 67 | ...5\ Adds tog| 000005e0 65 74 68 65 72 20 74 68 65 20 6e 75 6d 62 65 72 |ether the number| 000005f0 73 20 69 6e 20 66 70 77 73 5f 31 20 61 6e 64 20 |s in fpws_1 and | 00000600 66 70 77 73 5f 31 0d 02 e4 24 5c 20 20 61 6e 64 |fpws_1...$\ and| 00000610 20 70 75 74 73 20 74 68 65 20 72 65 73 75 6c 74 | puts the result| 00000620 20 69 6e 20 66 70 77 73 5f 31 0d 02 ee 05 20 0d | in fpws_1.... .| 00000630 02 f8 2d 5c 20 20 46 69 72 73 74 20 61 6c 6c 6f |..-\ First allo| 00000640 77 20 66 6f 72 20 7a 65 72 6f 73 20 69 6e 20 74 |w for zeros in t| 00000650 68 65 20 77 6f 72 6b 73 70 61 63 65 0d 03 02 06 |he workspace....| 00000660 20 20 0d 03 0c 10 4c 44 41 20 66 70 77 73 5f 32 | ....LDA fpws_2| 00000670 2b 31 0d 03 16 4a 84 41 20 66 70 77 73 5f 32 20 |+1...J.A fpws_2 | 00000680 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000690 20 5c 20 5a 65 72 6f 20 69 66 20 65 78 70 6f 6e | \ Zero if expon| 000006a0 65 6e 74 20 26 20 74 6f 70 20 6d 61 6e 74 69 73 |ent & top mantis| 000006b0 73 61 20 62 79 74 65 20 7a 65 72 6f 0d 03 20 41 |sa byte zero.. A| 000006c0 42 45 51 20 65 78 69 74 5f 61 64 64 69 74 69 6f |BEQ exit_additio| 000006d0 6e 20 20 20 20 20 20 20 20 20 20 20 5c 20 49 66 |n \ If| 000006e0 20 32 6e 64 20 6e 6f 20 69 73 20 30 20 20 72 65 | 2nd no is 0 re| 000006f0 73 75 6c 74 20 3d 20 31 73 74 20 6e 6f 0d 03 2a |sult = 1st no..*| 00000700 05 20 0d 03 34 10 4c 44 41 20 66 70 77 73 5f 31 |. ..4.LDA fpws_1| 00000710 2b 31 0d 03 3e 4a 84 41 20 66 70 77 73 5f 31 20 |+1..>J.A fpws_1 | 00000720 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000730 20 5c 20 5a 65 72 6f 20 69 66 20 65 78 70 6f 6e | \ Zero if expon| 00000740 65 6e 74 20 26 20 74 6f 70 20 6d 61 6e 74 69 73 |ent & top mantis| 00000750 73 61 20 62 79 74 65 20 7a 65 72 6f 0d 03 48 49 |sa byte zero..HI| 00000760 42 4e 45 20 64 6f 6e 74 5f 74 72 61 6e 73 66 65 |BNE dont_transfe| 00000770 72 20 20 20 20 20 20 20 20 20 20 20 5c 20 49 66 |r \ If| 00000780 20 6f 6e 6c 79 20 31 73 74 20 6e 6f 20 69 73 20 | only 1st no is | 00000790 7a 65 72 6f 20 61 6e 73 77 65 72 20 69 73 20 32 |zero answer is 2| 000007a0 6e 64 20 6e 6f 0d 03 52 05 20 0d 03 5c 0a 4c 44 |nd no..R. ..\.LD| 000007b0 58 20 23 35 0d 03 66 05 20 0d 03 70 47 2e 7a 65 |X #5..f. ..pG.ze| 000007c0 72 6f 5f 63 6f 6d 70 65 6e 73 61 74 69 6f 6e 5f |ro_compensation_| 000007d0 6c 6f 6f 70 20 20 20 20 20 20 5c 20 74 72 61 6e |loop \ tran| 000007e0 73 66 65 72 20 73 65 63 6f 6e 64 20 6e 6f 20 61 |sfer second no a| 000007f0 6e 64 20 65 78 69 74 20 61 64 64 69 74 69 6f 6e |nd exit addition| 00000800 0d 03 7a 05 20 0d 03 84 13 4c 44 41 20 66 70 77 |..z. ....LDA fpw| 00000810 73 5f 32 2d 31 2c 20 58 0d 03 8e 13 53 54 41 20 |s_2-1, X....STA | 00000820 66 70 77 73 5f 31 2d 31 2c 20 58 0d 03 98 07 44 |fpws_1-1, X....D| 00000830 45 58 0d 03 a2 1e 42 4e 45 20 7a 65 72 6f 5f 63 |EX....BNE zero_c| 00000840 6f 6d 70 65 6e 73 61 74 69 6f 6e 5f 6c 6f 6f 70 |ompensation_loop| 00000850 0d 03 ac 15 4a 4d 50 20 65 78 69 74 5f 61 64 64 |....JMP exit_add| 00000860 69 74 69 6f 6e 0d 03 b6 05 20 0d 03 c0 12 2e 64 |ition.... .....d| 00000870 6f 6e 74 5f 74 72 61 6e 73 66 65 72 0d 03 ca 05 |ont_transfer....| 00000880 20 0d 03 d4 3f 4a 53 52 20 6d 6f 76 65 5f 73 69 | ...?JSR move_si| 00000890 67 6e 5f 62 69 74 20 20 20 20 20 20 20 20 20 20 |gn_bit | 000008a0 20 5c 20 4d 6f 76 65 20 73 69 67 6e 20 61 6e 64 | \ Move sign and| 000008b0 20 72 65 73 74 6f 72 65 20 74 6f 70 20 62 69 74 | restore top bit| 000008c0 0d 03 de 05 20 0d 03 e8 3c 4a 53 52 20 65 71 75 |.... ...<JSR equ| 000008d0 61 74 65 5f 65 78 70 6f 6e 65 6e 74 73 20 20 20 |ate_exponents | 000008e0 20 20 20 20 20 5c 20 44 65 6e 6f 72 6d 61 6c 69 | \ Denormali| 000008f0 73 65 20 73 6d 61 6c 6c 65 72 20 6e 75 6d 62 65 |se smaller numbe| 00000900 72 0d 03 f2 05 20 0d 03 fc 43 4a 53 52 20 6e 65 |r.... ...CJSR ne| 00000910 67 5f 63 6f 6e 76 65 72 74 20 20 20 20 20 20 20 |g_convert | 00000920 20 20 20 20 20 20 5c 20 43 6f 6e 76 65 72 74 20 | \ Convert | 00000930 6e 65 67 20 6e 6f 73 20 74 6f 20 32 27 73 20 63 |neg nos to 2's c| 00000940 6f 6d 70 6c 65 6d 65 6e 74 0d 04 06 05 20 0d 04 |omplement.... ..| 00000950 10 15 4a 53 52 20 61 64 64 5f 6d 61 6e 74 69 73 |..JSR add_mantis| 00000960 73 61 65 0d 04 1a 05 20 0d 04 24 44 4a 53 52 20 |sae.... ..$DJSR | 00000970 6e 65 67 5f 63 6f 6e 76 65 72 74 5f 62 61 63 6b |neg_convert_back| 00000980 20 20 20 20 20 20 20 20 5c 20 43 6f 6e 76 65 72 | \ Conver| 00000990 74 20 32 27 73 20 63 6f 6d 70 6c 65 6d 65 6e 74 |t 2's complement| 000009a0 20 62 61 63 6b 20 74 6f 20 6e 65 67 0d 04 2e 05 | back to neg....| 000009b0 20 0d 04 38 49 5c 20 20 54 72 61 70 20 61 20 7a | ..8I\ Trap a z| 000009c0 65 72 6f 20 72 65 73 75 6c 74 20 6f 72 20 72 65 |ero result or re| 000009d0 6e 6f 72 6d 61 6c 69 73 69 6e 67 20 72 6f 75 74 |normalising rout| 000009e0 69 6e 65 20 77 69 6c 6c 20 6c 6f 6f 70 20 69 6e |ine will loop in| 000009f0 64 65 66 69 6e 61 74 65 6c 79 0d 04 42 05 20 0d |definately..B. .| 00000a00 04 4c 14 4c 44 41 20 66 70 77 73 5f 31 5f 6f 66 |.L.LDA fpws_1_of| 00000a10 6c 6f 77 0d 04 56 0f 84 41 20 66 70 77 73 5f 31 |low..V..A fpws_1| 00000a20 2b 31 0d 04 60 0f 84 41 20 66 70 77 73 5f 31 2b |+1..`..A fpws_1+| 00000a30 32 0d 04 6a 0f 84 41 20 66 70 77 73 5f 31 2b 33 |2..j..A fpws_1+3| 00000a40 0d 04 74 49 84 41 20 66 70 77 73 5f 31 2b 34 20 |..tI.A fpws_1+4 | 00000a50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c | \| 00000a60 20 84 69 6e 67 20 62 79 74 65 73 20 74 6f 67 65 | .ing bytes toge| 00000a70 74 68 65 72 20 67 69 76 65 73 20 30 20 69 66 20 |ther gives 0 if | 00000a80 61 6c 6c 20 61 72 65 20 30 0d 04 7e 05 20 0d 04 |all are 0..~. ..| 00000a90 88 43 42 45 51 20 7a 65 72 6f 5f 72 65 73 75 6c |.CBEQ zero_resul| 00000aa0 74 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 |t \ | 00000ab0 50 75 74 20 7a 65 72 6f 20 69 6e 74 6f 20 77 6f |Put zero into wo| 00000ac0 72 6b 73 70 61 63 65 20 74 68 65 6e 20 65 78 69 |rkspace then exi| 00000ad0 74 0d 04 92 05 20 0d 04 9c 13 4a 53 52 20 72 65 |t.... ....JSR re| 00000ae0 6e 6f 72 6d 61 6c 69 73 65 0d 04 a6 05 20 0d 04 |normalise.... ..| 00000af0 b0 3b 4a 53 52 20 72 65 70 6c 61 63 65 5f 73 69 |.;JSR replace_si| 00000b00 67 6e 5f 62 69 74 20 20 20 20 20 20 20 20 5c 20 |gn_bit \ | 00000b10 52 65 70 6c 61 63 65 20 74 6f 70 20 62 69 74 20 |Replace top bit | 00000b20 77 69 74 68 20 73 69 67 6e 0d 04 ba 05 20 0d 04 |with sign.... ..| 00000b30 c4 12 2e 65 78 69 74 5f 61 64 64 69 74 69 6f 6e |...exit_addition| 00000b40 0d 04 ce 05 20 0d 04 d8 07 52 54 53 0d 04 e2 05 |.... ....RTS....| 00000b50 20 0d 04 ec 10 2e 7a 65 72 6f 5f 72 65 73 75 6c | .....zero_resul| 00000b60 74 0d 04 f6 05 20 0d 05 00 0a 4c 44 41 20 23 30 |t.... ....LDA #0| 00000b70 0d 05 0a 41 53 54 41 20 66 70 77 73 5f 31 20 20 |...ASTA fpws_1 | 00000b80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000b90 5c 20 43 6c 65 61 72 20 65 78 70 6f 6e 65 6e 74 |\ Clear exponent| 00000ba0 20 6f 66 20 61 20 7a 65 72 6f 20 6e 75 6d 62 65 | of a zero numbe| 00000bb0 72 0d 05 14 05 20 0d 05 1e 07 52 54 53 0d 05 28 |r.... ....RTS..(| 00000bc0 05 20 0d 05 32 0b 2e 66 70 5f 73 75 62 0d 05 3c |. ..2..fp_sub..<| 00000bd0 06 20 20 0d 05 46 31 5c 20 20 53 75 62 74 72 61 |. ..F1\ Subtra| 00000be0 63 74 73 20 74 68 65 20 6e 75 6d 62 65 72 20 69 |cts the number i| 00000bf0 6e 20 66 70 77 73 5f 32 20 66 72 6f 6d 20 66 70 |n fpws_2 from fp| 00000c00 77 73 5f 31 0d 05 50 24 5c 20 20 61 6e 64 20 70 |ws_1..P$\ and p| 00000c10 75 74 73 20 74 68 65 20 72 65 73 75 6c 74 20 69 |uts the result i| 00000c20 6e 20 66 70 77 73 5f 31 0d 05 5a 05 20 0d 05 64 |n fpws_1..Z. ..d| 00000c30 2d 5c 20 20 46 69 72 73 74 20 61 6c 6c 6f 77 20 |-\ First allow | 00000c40 66 6f 72 20 7a 65 72 6f 73 20 69 6e 20 74 68 65 |for zeros in the| 00000c50 20 77 6f 72 6b 73 70 61 63 65 0d 05 6e 06 20 20 | workspace..n. | 00000c60 0d 05 78 10 4c 44 41 20 66 70 77 73 5f 32 2b 31 |..x.LDA fpws_2+1| 00000c70 0d 05 82 4a 84 41 20 66 70 77 73 5f 32 20 20 20 |...J.A fpws_2 | 00000c80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c | \| 00000c90 20 5a 65 72 6f 20 69 66 20 65 78 70 6f 6e 65 6e | Zero if exponen| 00000ca0 74 20 26 20 74 6f 70 20 6d 61 6e 74 69 73 73 61 |t & top mantissa| 00000cb0 20 62 79 74 65 20 7a 65 72 6f 0d 05 8c 41 42 45 | byte zero...ABE| 00000cc0 51 20 65 78 69 74 5f 73 75 62 74 72 61 63 74 69 |Q exit_subtracti| 00000cd0 6f 6e 20 20 20 20 20 20 20 20 5c 20 49 66 20 32 |on \ If 2| 00000ce0 6e 64 20 6e 6f 20 69 73 20 30 20 20 72 65 73 75 |nd no is 0 resu| 00000cf0 6c 74 20 3d 20 31 73 74 20 6e 6f 0d 05 96 05 20 |lt = 1st no.... | 00000d00 0d 05 a0 10 4c 44 41 20 66 70 77 73 5f 31 2b 31 |....LDA fpws_1+1| 00000d10 0d 05 aa 4a 84 41 20 66 70 77 73 5f 31 20 20 20 |...J.A fpws_1 | 00000d20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c | \| 00000d30 20 5a 65 72 6f 20 69 66 20 65 78 70 6f 6e 65 6e | Zero if exponen| 00000d40 74 20 26 20 74 6f 70 20 6d 61 6e 74 69 73 73 61 |t & top mantissa| 00000d50 20 62 79 74 65 20 7a 65 72 6f 0d 05 b4 4a 42 4e | byte zero...JBN| 00000d60 45 20 64 6f 6e 74 5f 74 72 61 6e 73 66 65 72 5f |E dont_transfer_| 00000d70 73 75 62 20 20 20 20 20 20 20 5c 20 49 66 20 6f |sub \ If o| 00000d80 6e 6c 79 20 31 73 74 20 6e 6f 20 69 73 20 7a 65 |nly 1st no is ze| 00000d90 72 6f 20 61 6e 73 77 65 72 20 69 73 20 2d 32 6e |ro answer is -2n| 00000da0 64 20 6e 6f 0d 05 be 05 20 0d 05 c8 0a 4c 44 58 |d no.... ....LDX| 00000db0 20 23 35 0d 05 d2 05 20 0d 05 dc 4a 2e 7a 65 72 | #5.... ...J.zer| 00000dc0 6f 5f 63 6f 6d 70 65 6e 73 61 74 69 6f 6e 5f 6c |o_compensation_l| 00000dd0 6f 6f 70 32 20 20 20 20 20 5c 20 74 72 61 6e 73 |oop2 \ trans| 00000de0 66 65 72 20 73 65 63 6f 6e 64 20 6e 6f 20 61 6e |fer second no an| 00000df0 64 20 65 78 69 74 20 73 75 62 74 72 61 63 74 69 |d exit subtracti| 00000e00 6f 6e 0d 05 e6 05 20 0d 05 f0 13 4c 44 41 20 66 |on.... ....LDA f| 00000e10 70 77 73 5f 32 2d 31 2c 20 58 0d 05 fa 13 53 54 |pws_2-1, X....ST| 00000e20 41 20 66 70 77 73 5f 31 2d 31 2c 20 58 0d 06 04 |A fpws_1-1, X...| 00000e30 07 44 45 58 0d 06 0e 1f 42 4e 45 20 7a 65 72 6f |.DEX....BNE zero| 00000e40 5f 63 6f 6d 70 65 6e 73 61 74 69 6f 6e 5f 6c 6f |_compensation_lo| 00000e50 6f 70 32 0d 06 18 10 4c 44 41 20 66 70 77 73 5f |op2....LDA fpws_| 00000e60 31 2b 31 0d 06 22 0a 82 20 23 26 38 30 0d 06 2c |1+1..".. #&80..,| 00000e70 49 53 54 41 20 66 70 77 73 5f 31 2b 31 20 20 20 |ISTA fpws_1+1 | 00000e80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 | \ | 00000e90 43 68 61 6e 67 65 20 73 69 67 6e 20 6f 66 20 73 |Change sign of s| 00000ea0 65 63 6f 6e 64 20 6e 75 6d 62 65 72 20 2d 3e 20 |econd number -> | 00000eb0 72 65 73 75 6c 74 0d 06 36 18 4a 4d 50 20 65 78 |result..6.JMP ex| 00000ec0 69 74 5f 73 75 62 74 72 61 63 74 69 6f 6e 0d 06 |it_subtraction..| 00000ed0 40 05 20 0d 06 4a 16 2e 64 6f 6e 74 5f 74 72 61 |@. ..J..dont_tra| 00000ee0 6e 73 66 65 72 5f 73 75 62 0d 06 54 05 20 0d 06 |nsfer_sub..T. ..| 00000ef0 5e 3f 4a 53 52 20 6d 6f 76 65 5f 73 69 67 6e 5f |^?JSR move_sign_| 00000f00 62 69 74 20 20 20 20 20 20 20 20 20 20 20 5c 20 |bit \ | 00000f10 4d 6f 76 65 20 73 69 67 6e 20 61 6e 64 20 72 65 |Move sign and re| 00000f20 73 74 6f 72 65 20 74 6f 70 20 62 69 74 0d 06 68 |store top bit..h| 00000f30 05 20 0d 06 72 3c 4a 53 52 20 65 71 75 61 74 65 |. ..r<JSR equate| 00000f40 5f 65 78 70 6f 6e 65 6e 74 73 20 20 20 20 20 20 |_exponents | 00000f50 20 20 5c 20 44 65 6e 6f 72 6d 61 6c 69 73 65 20 | \ Denormalise | 00000f60 73 6d 61 6c 6c 65 72 20 6e 75 6d 62 65 72 0d 06 |smaller number..| 00000f70 7c 05 20 0d 06 86 43 4a 53 52 20 6e 65 67 5f 63 ||. ...CJSR neg_c| 00000f80 6f 6e 76 65 72 74 20 20 20 20 20 20 20 20 20 20 |onvert | 00000f90 20 20 20 5c 20 43 6f 6e 76 65 72 74 20 6e 65 67 | \ Convert neg| 00000fa0 20 6e 6f 73 20 74 6f 20 32 27 73 20 63 6f 6d 70 | nos to 2's comp| 00000fb0 6c 65 6d 65 6e 74 0d 06 90 05 20 0d 06 9a 1a 4a |lement.... ....J| 00000fc0 53 52 20 73 75 62 74 72 61 63 74 5f 6d 61 6e 74 |SR subtract_mant| 00000fd0 69 73 73 61 65 0d 06 a4 05 20 0d 06 ae 44 4a 53 |issae.... ...DJS| 00000fe0 52 20 6e 65 67 5f 63 6f 6e 76 65 72 74 5f 62 61 |R neg_convert_ba| 00000ff0 63 6b 20 20 20 20 20 20 20 20 5c 20 43 6f 6e 76 |ck \ Conv| 00001000 65 72 74 20 32 27 73 20 63 6f 6d 70 6c 65 6d 65 |ert 2's compleme| 00001010 6e 74 20 62 61 63 6b 20 74 6f 20 6e 65 67 0d 06 |nt back to neg..| 00001020 b8 05 20 0d 06 c2 49 5c 20 20 54 72 61 70 20 61 |.. ...I\ Trap a| 00001030 20 7a 65 72 6f 20 72 65 73 75 6c 74 20 6f 72 20 | zero result or | 00001040 72 65 6e 6f 72 6d 61 6c 69 73 69 6e 67 20 72 6f |renormalising ro| 00001050 75 74 69 6e 65 20 77 69 6c 6c 20 6c 6f 6f 70 20 |utine will loop | 00001060 69 6e 64 65 66 69 6e 61 74 65 6c 79 0d 06 cc 05 |indefinately....| 00001070 20 0d 06 d6 14 4c 44 41 20 66 70 77 73 5f 31 5f | ....LDA fpws_1_| 00001080 6f 66 6c 6f 77 0d 06 e0 0f 84 41 20 66 70 77 73 |oflow.....A fpws| 00001090 5f 31 2b 31 0d 06 ea 0f 84 41 20 66 70 77 73 5f |_1+1.....A fpws_| 000010a0 31 2b 32 0d 06 f4 0f 84 41 20 66 70 77 73 5f 31 |1+2.....A fpws_1| 000010b0 2b 33 0d 06 fe 49 84 41 20 66 70 77 73 5f 31 2b |+3...I.A fpws_1+| 000010c0 34 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |4 | 000010d0 20 5c 20 84 69 6e 67 20 62 79 74 65 73 20 74 6f | \ .ing bytes to| 000010e0 67 65 74 68 65 72 20 67 69 76 65 73 20 30 20 69 |gether gives 0 i| 000010f0 66 20 61 6c 6c 20 61 72 65 20 30 0d 07 08 05 20 |f all are 0.... | 00001100 0d 07 12 43 42 45 51 20 7a 65 72 6f 5f 72 65 73 |...CBEQ zero_res| 00001110 75 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 20 |ult | 00001120 5c 20 50 75 74 20 7a 65 72 6f 20 69 6e 74 6f 20 |\ Put zero into | 00001130 77 6f 72 6b 73 70 61 63 65 20 74 68 65 6e 20 65 |workspace then e| 00001140 78 69 74 0d 07 1c 05 20 0d 07 26 13 4a 53 52 20 |xit.... ..&.JSR | 00001150 72 65 6e 6f 72 6d 61 6c 69 73 65 0d 07 30 05 20 |renormalise..0. | 00001160 0d 07 3a 3b 4a 53 52 20 72 65 70 6c 61 63 65 5f |..:;JSR replace_| 00001170 73 69 67 6e 5f 62 69 74 20 20 20 20 20 20 20 20 |sign_bit | 00001180 5c 20 52 65 70 6c 61 63 65 20 74 6f 70 20 62 69 |\ Replace top bi| 00001190 74 20 77 69 74 68 20 73 69 67 6e 0d 07 44 05 20 |t with sign..D. | 000011a0 0d 07 4e 15 2e 65 78 69 74 5f 73 75 62 74 72 61 |..N..exit_subtra| 000011b0 63 74 69 6f 6e 0d 07 58 05 20 0d 07 62 07 52 54 |ction..X. ..b.RT| 000011c0 53 0d 07 6c 05 20 0d 07 76 10 2e 74 72 61 6e 73 |S..l. ..v..trans| 000011d0 66 65 72 5f 69 6e 0d 07 80 05 20 0d 07 8a 37 5c |fer_in.... ...7\| 000011e0 20 20 54 68 69 73 20 73 75 62 72 6f 75 74 69 6e | This subroutin| 000011f0 65 20 74 61 6b 65 73 20 74 68 65 20 6e 75 6d 62 |e takes the numb| 00001200 65 72 73 20 69 6e 20 69 6e 70 75 74 5f 31 20 61 |ers in input_1 a| 00001210 6e 64 0d 07 94 31 5c 20 20 69 6e 70 75 74 5f 32 |nd...1\ input_2| 00001220 20 61 6e 64 20 70 75 74 73 20 74 68 65 6d 20 69 | and puts them i| 00001230 6e 20 66 70 77 73 5f 31 20 61 6e 64 20 66 70 77 |n fpws_1 and fpw| 00001240 73 5f 32 0d 07 9e 05 20 0d 07 a8 0a 4c 44 58 20 |s_2.... ....LDX | 00001250 23 35 0d 07 b2 05 20 0d 07 bc 15 2e 74 72 61 6e |#5.... .....tran| 00001260 73 66 65 72 5f 69 6e 5f 6c 6f 6f 70 0d 07 c6 05 |sfer_in_loop....| 00001270 20 0d 07 d0 14 4c 44 41 20 69 6e 70 75 74 5f 31 | ....LDA input_1| 00001280 2d 31 2c 20 58 0d 07 da 13 53 54 41 20 66 70 77 |-1, X....STA fpw| 00001290 73 5f 31 2d 31 2c 20 58 0d 07 e4 14 4c 44 41 20 |s_1-1, X....LDA | 000012a0 69 6e 70 75 74 5f 32 2d 31 2c 20 58 0d 07 ee 13 |input_2-1, X....| 000012b0 53 54 41 20 66 70 77 73 5f 32 2d 31 2c 20 58 0d |STA fpws_2-1, X.| 000012c0 07 f8 07 44 45 58 0d 08 02 19 42 4e 45 20 74 72 |...DEX....BNE tr| 000012d0 61 6e 73 66 65 72 5f 69 6e 5f 6c 6f 6f 70 20 0d |ansfer_in_loop .| 000012e0 08 0c 05 20 0d 08 16 0a 4c 44 41 20 23 30 0d 08 |... ....LDA #0..| 000012f0 20 14 53 54 41 20 66 70 77 73 5f 31 5f 6f 66 6c | .STA fpws_1_ofl| 00001300 6f 77 0d 08 2a 14 53 54 41 20 66 70 77 73 5f 32 |ow..*.STA fpws_2| 00001310 5f 6f 66 6c 6f 77 0d 08 34 05 20 0d 08 3e 07 52 |_oflow..4. ..>.R| 00001320 54 53 0d 08 48 05 20 0d 08 52 12 2e 6d 6f 76 65 |TS..H. ..R..move| 00001330 5f 73 69 67 6e 5f 62 69 74 0d 08 5c 05 20 0d 08 |_sign_bit..\. ..| 00001340 66 48 5c 20 20 54 68 69 73 20 72 6f 75 74 69 6e |fH\ This routin| 00001350 65 20 74 72 61 6e 73 66 65 72 73 20 74 68 65 20 |e transfers the | 00001360 73 69 67 6e 20 62 69 74 20 66 72 6f 6d 20 74 68 |sign bit from th| 00001370 65 20 74 6f 70 20 6f 66 20 74 68 65 20 6d 61 6e |e top of the man| 00001380 74 69 73 73 61 65 0d 08 70 40 5c 20 20 61 6e 64 |tissae..p@\ and| 00001390 20 70 75 74 73 20 69 74 20 69 6e 74 6f 20 61 20 | puts it into a | 000013a0 73 69 67 6e 20 62 79 74 65 20 2d 20 80 69 6e 67 |sign byte - .ing| 000013b0 20 74 6f 20 6c 65 61 76 65 20 74 6f 70 20 62 69 | to leave top bi| 000013c0 74 20 6f 6e 6c 79 0d 08 7a 35 5c 20 20 61 6e 64 |t only..z5\ and| 000013d0 20 74 68 65 6e 20 72 65 73 74 6f 72 65 73 20 74 | then restores t| 000013e0 68 65 20 74 6f 70 20 62 69 74 20 6f 66 20 74 68 |he top bit of th| 000013f0 65 20 6d 61 6e 74 69 73 73 61 65 0d 08 84 06 20 |e mantissae.... | 00001400 20 0d 08 8e 10 4c 44 41 20 66 70 77 73 5f 31 2b | ....LDA fpws_1+| 00001410 31 0d 08 98 0a 80 20 23 26 38 30 0d 08 a2 46 53 |1..... #&80...FS| 00001420 54 41 20 66 70 77 73 5f 31 5f 73 69 67 6e 20 20 |TA fpws_1_sign | 00001430 20 20 20 20 20 20 20 20 20 20 20 5c 20 66 70 77 | \ fpw| 00001440 73 5f 31 5f 73 69 67 6e 20 69 73 20 2d 76 65 20 |s_1_sign is -ve | 00001450 69 66 20 6e 75 6d 62 65 72 20 77 61 73 20 2d 76 |if number was -v| 00001460 65 0d 08 ac 0c 4c 44 41 20 23 26 38 30 0d 08 b6 |e....LDA #&80...| 00001470 0f 84 41 20 66 70 77 73 5f 31 2b 31 0d 08 c0 44 |..A fpws_1+1...D| 00001480 53 54 41 20 66 70 77 73 5f 31 2b 31 20 20 20 20 |STA fpws_1+1 | 00001490 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 52 65 | \ Re| 000014a0 73 74 6f 72 65 73 20 74 68 65 20 74 6f 70 20 62 |stores the top b| 000014b0 69 74 20 6f 66 20 74 68 65 20 6e 75 6d 62 65 72 |it of the number| 000014c0 0d 08 ca 05 20 0d 08 d4 10 4c 44 41 20 66 70 77 |.... ....LDA fpw| 000014d0 73 5f 32 2b 31 0d 08 de 0a 80 20 23 26 38 30 0d |s_2+1..... #&80.| 000014e0 08 e8 46 53 54 41 20 66 70 77 73 5f 32 5f 73 69 |..FSTA fpws_2_si| 000014f0 67 6e 20 20 20 20 20 20 20 20 20 20 20 20 20 5c |gn \| 00001500 20 66 70 77 73 5f 32 5f 73 69 67 6e 20 69 73 20 | fpws_2_sign is | 00001510 2d 76 65 20 69 66 20 6e 75 6d 62 65 72 20 77 61 |-ve if number wa| 00001520 73 20 2d 76 65 0d 08 f2 0c 4c 44 41 20 23 26 38 |s -ve....LDA #&8| 00001530 30 0d 08 fc 0f 84 41 20 66 70 77 73 5f 32 2b 31 |0.....A fpws_2+1| 00001540 0d 09 06 44 53 54 41 20 66 70 77 73 5f 32 2b 31 |...DSTA fpws_2+1| 00001550 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001560 5c 20 52 65 73 74 6f 72 65 73 20 74 68 65 20 74 |\ Restores the t| 00001570 6f 70 20 62 69 74 20 6f 66 20 74 68 65 20 6e 75 |op bit of the nu| 00001580 6d 62 65 72 0d 09 10 05 20 0d 09 1a 07 52 54 53 |mber.... ....RTS| 00001590 0d 09 24 05 20 0d 09 2e 15 2e 65 71 75 61 74 65 |..$. .....equate| 000015a0 5f 65 78 70 6f 6e 65 6e 74 73 0d 09 38 05 20 0d |_exponents..8. .| 000015b0 09 42 45 5c 20 20 54 68 69 73 20 72 6f 75 74 69 |.BE\ This routi| 000015c0 6e 65 20 6d 6f 64 69 66 69 65 73 20 74 68 65 20 |ne modifies the | 000015d0 73 6d 61 6c 6c 65 72 20 6e 75 6d 62 65 72 20 73 |smaller number s| 000015e0 6f 20 74 68 61 74 20 74 68 65 20 65 78 70 6f 6e |o that the expon| 000015f0 65 6e 74 73 0d 09 4c 13 5c 20 20 61 72 65 20 74 |ents..L.\ are t| 00001600 68 65 20 73 61 6d 65 0d 09 56 05 20 0d 09 60 07 |he same..V. ..`.| 00001610 53 45 43 0d 09 6a 0e 4c 44 41 20 66 70 77 73 5f |SEC..j.LDA fpws_| 00001620 31 0d 09 74 40 53 42 43 20 66 70 77 73 5f 32 20 |1..t@SBC fpws_2 | 00001630 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001640 20 5c 20 46 69 6e 64 20 77 68 69 63 68 20 65 78 | \ Find which ex| 00001650 70 6f 6e 65 6e 74 20 69 73 20 67 72 65 61 74 65 |ponent is greate| 00001660 72 0d 09 7e 17 42 45 51 20 65 78 70 6f 6e 65 6e |r..~.BEQ exponen| 00001670 74 73 5f 65 71 75 61 6c 0d 09 88 16 42 50 4c 20 |ts_equal....BPL | 00001680 77 73 31 5f 69 73 5f 67 72 65 61 74 65 72 0d 09 |ws1_is_greater..| 00001690 92 05 20 0d 09 9c 13 2e 77 73 32 5f 69 73 5f 67 |.. .....ws2_is_g| 000016a0 72 65 61 74 65 72 0d 09 a6 05 20 0d 09 b0 3e 49 |reater.... ...>I| 000016b0 4e 43 20 66 70 77 73 5f 31 20 20 20 20 20 20 20 |NC fpws_1 | 000016c0 20 20 20 20 20 20 20 20 20 20 20 5c 20 49 6e 63 | \ Inc| 000016d0 72 65 61 73 65 20 74 68 65 20 6c 65 73 73 65 72 |rease the lesser| 000016e0 20 65 78 70 6f 6e 65 6e 74 0d 09 ba 44 4c 53 52 | exponent...DLSR| 000016f0 20 66 70 77 73 5f 31 2b 31 20 20 20 20 20 20 20 | fpws_1+1 | 00001700 20 20 20 20 20 20 20 20 20 5c 20 53 68 69 66 74 | \ Shift| 00001710 20 6d 61 6e 74 69 73 73 61 20 72 69 67 68 74 20 | mantissa right | 00001720 74 6f 20 63 6f 6d 70 65 6e 73 61 74 65 0d 09 c4 |to compensate...| 00001730 10 52 4f 52 20 66 70 77 73 5f 31 2b 32 0d 09 ce |.ROR fpws_1+2...| 00001740 10 52 4f 52 20 66 70 77 73 5f 31 2b 33 0d 09 d8 |.ROR fpws_1+3...| 00001750 10 52 4f 52 20 66 70 77 73 5f 31 2b 34 0d 09 e2 |.ROR fpws_1+4...| 00001760 05 20 0d 09 ec 0e 4c 44 41 20 66 70 77 73 5f 32 |. ....LDA fpws_2| 00001770 0d 09 f6 0e 43 4d 50 20 66 70 77 73 5f 31 0d 0a |....CMP fpws_1..| 00001780 00 41 42 4e 45 20 77 73 32 5f 69 73 5f 67 72 65 |.ABNE ws2_is_gre| 00001790 61 74 65 72 20 20 20 20 20 20 20 20 20 20 5c 20 |ater \ | 000017a0 46 69 6e 69 73 68 20 77 68 65 6e 20 65 78 70 6f |Finish when expo| 000017b0 6e 65 6e 74 73 20 61 72 65 20 65 71 75 61 6c 0d |nents are equal.| 000017c0 0a 0a 07 52 54 53 0d 0a 14 05 20 0d 0a 1e 13 2e |...RTS.... .....| 000017d0 77 73 31 5f 69 73 5f 67 72 65 61 74 65 72 0d 0a |ws1_is_greater..| 000017e0 28 05 20 0d 0a 32 3a 49 4e 43 20 66 70 77 73 5f |(. ..2:INC fpws_| 000017f0 32 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |2 | 00001800 20 20 20 5c 20 49 6e 63 72 65 61 73 65 20 6c 65 | \ Increase le| 00001810 73 73 65 72 20 65 78 70 6f 6e 65 6e 74 0d 0a 3c |sser exponent..<| 00001820 44 4c 53 52 20 66 70 77 73 5f 32 2b 31 20 20 20 |DLSR fpws_2+1 | 00001830 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 53 | \ S| 00001840 68 69 66 74 20 6d 61 6e 74 69 73 73 61 20 72 69 |hift mantissa ri| 00001850 67 68 74 20 74 6f 20 63 6f 6d 70 65 6e 73 61 74 |ght to compensat| 00001860 65 0d 0a 46 10 52 4f 52 20 66 70 77 73 5f 32 2b |e..F.ROR fpws_2+| 00001870 32 0d 0a 50 10 52 4f 52 20 66 70 77 73 5f 32 2b |2..P.ROR fpws_2+| 00001880 33 0d 0a 5a 10 52 4f 52 20 66 70 77 73 5f 32 2b |3..Z.ROR fpws_2+| 00001890 34 0d 0a 64 05 20 0d 0a 6e 0e 4c 44 41 20 66 70 |4..d. ..n.LDA fp| 000018a0 77 73 5f 31 0d 0a 78 0e 43 4d 50 20 66 70 77 73 |ws_1..x.CMP fpws| 000018b0 5f 32 0d 0a 82 40 42 4e 45 20 77 73 31 5f 69 73 |_2...@BNE ws1_is| 000018c0 5f 67 72 65 61 74 65 72 20 20 20 20 20 20 20 20 |_greater | 000018d0 20 5c 20 46 69 6e 69 73 68 20 77 68 65 6e 20 65 | \ Finish when e| 000018e0 78 70 6f 6e 65 6e 74 73 20 61 72 65 20 65 71 75 |xponents are equ| 000018f0 61 6c 0d 0a 8c 05 20 0d 0a 96 14 2e 65 78 70 6f |al.... .....expo| 00001900 6e 65 6e 74 73 5f 65 71 75 61 6c 0d 0a a0 05 20 |nents_equal.... | 00001910 0d 0a aa 07 52 54 53 0d 0a b4 05 20 0d 0a be 10 |....RTS.... ....| 00001920 2e 6e 65 67 5f 63 6f 6e 76 65 72 74 0d 0a c8 05 |.neg_convert....| 00001930 20 0d 0a d2 45 5c 20 20 42 65 63 61 75 73 65 20 | ...E\ Because | 00001940 74 68 65 20 66 70 20 66 6f 72 6d 61 74 20 69 73 |the fp format is| 00001950 20 6e 6f 74 20 32 27 73 20 63 6f 6d 70 6c 65 6d | not 2's complem| 00001960 65 6e 74 20 77 65 20 68 61 76 65 20 74 6f 20 63 |ent we have to c| 00001970 6f 6e 76 65 72 74 0d 0a dc 46 5c 20 20 6e 65 67 |onvert...F\ neg| 00001980 61 74 69 76 65 20 6e 75 6d 62 65 72 73 20 74 6f |ative numbers to| 00001990 20 32 27 73 20 63 6f 6d 70 6c 65 6d 65 6e 74 20 | 2's complement | 000019a0 62 65 66 6f 72 65 20 63 61 6c 63 75 6c 61 74 69 |before calculati| 000019b0 6e 67 20 77 69 74 68 20 74 68 65 6d 0d 0a e6 24 |ng with them...$| 000019c0 5c 20 20 66 6f 72 20 61 64 64 69 74 69 6f 6e 20 |\ for addition | 000019d0 61 6e 64 20 73 75 62 74 72 61 63 74 69 6f 6e 2e |and subtraction.| 000019e0 0d 0a f0 05 20 0d 0a fa 13 4c 44 41 20 66 70 77 |.... ....LDA fpw| 000019f0 73 5f 32 5f 73 69 67 6e 0d 0b 04 0f 42 50 4c 20 |s_2_sign....BPL | 00001a00 66 70 32 5f 70 6f 73 0d 0b 0e 05 20 0d 0b 18 34 |fp2_pos.... ...4| 00001a10 53 45 43 20 20 20 20 20 20 20 20 20 20 20 20 20 |SEC | 00001a20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 53 75 | \ Su| 00001a30 62 74 72 61 63 74 20 66 72 6f 6d 20 7a 65 72 6f |btract from zero| 00001a40 0d 0b 22 0a 4c 44 41 20 23 30 0d 0b 2c 10 53 42 |..".LDA #0..,.SB| 00001a50 43 20 66 70 77 73 5f 32 2b 34 0d 0b 36 10 53 54 |C fpws_2+4..6.ST| 00001a60 41 20 66 70 77 73 5f 32 2b 34 0d 0b 40 0a 4c 44 |A fpws_2+4..@.LD| 00001a70 41 20 23 30 0d 0b 4a 10 53 42 43 20 66 70 77 73 |A #0..J.SBC fpws| 00001a80 5f 32 2b 33 0d 0b 54 10 53 54 41 20 66 70 77 73 |_2+3..T.STA fpws| 00001a90 5f 32 2b 33 0d 0b 5e 0a 4c 44 41 20 23 30 0d 0b |_2+3..^.LDA #0..| 00001aa0 68 10 53 42 43 20 66 70 77 73 5f 32 2b 32 0d 0b |h.SBC fpws_2+2..| 00001ab0 72 10 53 54 41 20 66 70 77 73 5f 32 2b 32 0d 0b |r.STA fpws_2+2..| 00001ac0 7c 0a 4c 44 41 20 23 30 0d 0b 86 10 53 42 43 20 ||.LDA #0....SBC | 00001ad0 66 70 77 73 5f 32 2b 31 0d 0b 90 10 53 54 41 20 |fpws_2+1....STA | 00001ae0 66 70 77 73 5f 32 2b 31 0d 0b 9a 0a 4c 44 41 20 |fpws_2+1....LDA | 00001af0 23 30 0d 0b a4 46 53 42 43 20 66 70 77 73 5f 32 |#0...FSBC fpws_2| 00001b00 5f 6f 66 6c 6f 77 20 20 20 20 20 20 20 20 20 20 |_oflow | 00001b10 20 20 5c 20 44 6f 6e 27 74 20 66 6f 72 67 65 74 | \ Don't forget| 00001b20 20 74 6f 20 69 6e 63 6c 75 64 65 20 74 68 65 20 | to include the | 00001b30 6f 76 65 72 66 6c 6f 77 0d 0b ae 14 53 54 41 20 |overflow....STA | 00001b40 66 70 77 73 5f 32 5f 6f 66 6c 6f 77 0d 0b b8 05 |fpws_2_oflow....| 00001b50 20 0d 0b c2 0c 2e 66 70 32 5f 70 6f 73 0d 0b cc | .....fp2_pos...| 00001b60 05 20 0d 0b d6 13 4c 44 41 20 66 70 77 73 5f 31 |. ....LDA fpws_1| 00001b70 5f 73 69 67 6e 0d 0b e0 0f 42 50 4c 20 66 70 31 |_sign....BPL fp1| 00001b80 5f 70 6f 73 0d 0b ea 05 20 0d 0b f4 17 2e 63 6f |_pos.... .....co| 00001b90 6e 76 65 72 74 5f 73 69 67 6e 5f 66 70 77 73 31 |nvert_sign_fpws1| 00001ba0 0d 0b fe 05 20 0d 0c 08 34 53 45 43 20 20 20 20 |.... ...4SEC | 00001bb0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001bc0 20 20 20 20 20 5c 20 53 75 62 74 72 61 63 74 20 | \ Subtract | 00001bd0 66 72 6f 6d 20 7a 65 72 6f 0d 0c 12 0a 4c 44 41 |from zero....LDA| 00001be0 20 23 30 0d 0c 1c 10 53 42 43 20 66 70 77 73 5f | #0....SBC fpws_| 00001bf0 31 2b 34 0d 0c 26 10 53 54 41 20 66 70 77 73 5f |1+4..&.STA fpws_| 00001c00 31 2b 34 0d 0c 30 0a 4c 44 41 20 23 30 0d 0c 3a |1+4..0.LDA #0..:| 00001c10 10 53 42 43 20 66 70 77 73 5f 31 2b 33 0d 0c 44 |.SBC fpws_1+3..D| 00001c20 10 53 54 41 20 66 70 77 73 5f 31 2b 33 0d 0c 4e |.STA fpws_1+3..N| 00001c30 0a 4c 44 41 20 23 30 0d 0c 58 10 53 42 43 20 66 |.LDA #0..X.SBC f| 00001c40 70 77 73 5f 31 2b 32 0d 0c 62 10 53 54 41 20 66 |pws_1+2..b.STA f| 00001c50 70 77 73 5f 31 2b 32 0d 0c 6c 0a 4c 44 41 20 23 |pws_1+2..l.LDA #| 00001c60 30 0d 0c 76 10 53 42 43 20 66 70 77 73 5f 31 2b |0..v.SBC fpws_1+| 00001c70 31 0d 0c 80 10 53 54 41 20 66 70 77 73 5f 31 2b |1....STA fpws_1+| 00001c80 31 0d 0c 8a 0a 4c 44 41 20 23 30 0d 0c 94 2a 53 |1....LDA #0...*S| 00001c90 42 43 20 66 70 77 73 5f 31 5f 6f 66 6c 6f 77 20 |BC fpws_1_oflow | 00001ca0 20 20 20 20 20 20 20 20 20 20 20 5c 20 4f 76 65 | \ Ove| 00001cb0 72 66 6c 6f 77 0d 0c 9e 14 53 54 41 20 66 70 77 |rflow....STA fpw| 00001cc0 73 5f 31 5f 6f 66 6c 6f 77 0d 0c a8 05 20 0d 0c |s_1_oflow.... ..| 00001cd0 b2 0d 2e 20 66 70 31 5f 70 6f 73 0d 0c bc 05 20 |... fp1_pos.... | 00001ce0 0d 0c c6 07 52 54 53 0d 0c d0 05 20 0d 0c da 12 |....RTS.... ....| 00001cf0 2e 61 64 64 5f 6d 61 6e 74 69 73 73 61 65 0d 0c |.add_mantissae..| 00001d00 e4 05 20 0d 0c ee 35 5c 20 20 54 68 69 73 20 72 |.. ...5\ This r| 00001d10 6f 75 74 69 6e 65 20 61 64 64 73 20 74 68 65 20 |outine adds the | 00001d20 6d 61 6e 74 69 73 73 61 65 20 77 69 74 68 20 6f |mantissae with o| 00001d30 76 65 72 66 6c 6f 77 73 0d 0c f8 05 20 0d 0d 02 |verflows.... ...| 00001d40 07 43 4c 43 0d 0d 0c 46 4c 44 41 20 66 70 77 73 |.CLC...FLDA fpws| 00001d50 5f 31 2b 34 20 20 20 20 20 20 20 20 20 20 20 20 |_1+4 | 00001d60 20 20 20 20 5c 20 53 74 61 6e 64 61 72 64 20 61 | \ Standard a| 00001d70 64 64 20 62 75 74 20 77 69 74 68 20 62 79 74 65 |dd but with byte| 00001d80 73 20 72 65 76 65 72 73 65 64 0d 0d 16 10 41 44 |s reversed....AD| 00001d90 43 20 66 70 77 73 5f 32 2b 34 0d 0d 20 10 53 54 |C fpws_2+4.. .ST| 00001da0 41 20 66 70 77 73 5f 31 2b 34 0d 0d 2a 10 4c 44 |A fpws_1+4..*.LD| 00001db0 41 20 66 70 77 73 5f 31 2b 33 0d 0d 34 10 41 44 |A fpws_1+3..4.AD| 00001dc0 43 20 66 70 77 73 5f 32 2b 33 0d 0d 3e 10 53 54 |C fpws_2+3..>.ST| 00001dd0 41 20 66 70 77 73 5f 31 2b 33 0d 0d 48 10 4c 44 |A fpws_1+3..H.LD| 00001de0 41 20 66 70 77 73 5f 31 2b 32 0d 0d 52 10 41 44 |A fpws_1+2..R.AD| 00001df0 43 20 66 70 77 73 5f 32 2b 32 0d 0d 5c 10 53 54 |C fpws_2+2..\.ST| 00001e00 41 20 66 70 77 73 5f 31 2b 32 0d 0d 66 10 4c 44 |A fpws_1+2..f.LD| 00001e10 41 20 66 70 77 73 5f 31 2b 31 0d 0d 70 10 41 44 |A fpws_1+1..p.AD| 00001e20 43 20 66 70 77 73 5f 32 2b 31 0d 0d 7a 10 53 54 |C fpws_2+1..z.ST| 00001e30 41 20 66 70 77 73 5f 31 2b 31 0d 0d 84 14 4c 44 |A fpws_1+1....LD| 00001e40 41 20 66 70 77 73 5f 31 5f 6f 66 6c 6f 77 0d 0d |A fpws_1_oflow..| 00001e50 8e 14 41 44 43 20 66 70 77 73 5f 32 5f 6f 66 6c |..ADC fpws_2_ofl| 00001e60 6f 77 0d 0d 98 14 53 54 41 20 66 70 77 73 5f 31 |ow....STA fpws_1| 00001e70 5f 6f 66 6c 6f 77 0d 0d a2 05 20 0d 0d ac 07 52 |_oflow.... ....R| 00001e80 54 53 0d 0d b6 05 20 0d 0d c0 17 2e 73 75 62 74 |TS.... .....subt| 00001e90 72 61 63 74 5f 6d 61 6e 74 69 73 73 61 65 0d 0d |ract_mantissae..| 00001ea0 ca 05 20 0d 0d d4 3a 5c 20 20 54 68 69 73 20 72 |.. ...:\ This r| 00001eb0 6f 75 74 69 6e 65 20 73 75 62 74 72 61 63 74 73 |outine subtracts| 00001ec0 20 74 68 65 20 6d 61 6e 74 69 73 73 61 65 20 77 | the mantissae w| 00001ed0 69 74 68 20 6f 76 65 72 66 6c 6f 77 73 0d 0d de |ith overflows...| 00001ee0 05 20 0d 0d e8 07 53 45 43 0d 0d f2 4b 4c 44 41 |. ....SEC...KLDA| 00001ef0 20 66 70 77 73 5f 31 2b 34 20 20 20 20 20 20 20 | fpws_1+4 | 00001f00 20 20 20 20 20 20 20 20 20 5c 20 53 74 61 6e 64 | \ Stand| 00001f10 61 72 64 20 73 75 62 74 72 61 63 74 20 62 75 74 |ard subtract but| 00001f20 20 77 69 74 68 20 62 79 74 65 73 20 72 65 76 65 | with bytes reve| 00001f30 72 73 65 64 0d 0d fc 10 53 42 43 20 66 70 77 73 |rsed....SBC fpws| 00001f40 5f 32 2b 34 0d 0e 06 10 53 54 41 20 66 70 77 73 |_2+4....STA fpws| 00001f50 5f 31 2b 34 0d 0e 10 10 4c 44 41 20 66 70 77 73 |_1+4....LDA fpws| 00001f60 5f 31 2b 33 0d 0e 1a 10 53 42 43 20 66 70 77 73 |_1+3....SBC fpws| 00001f70 5f 32 2b 33 0d 0e 24 10 53 54 41 20 66 70 77 73 |_2+3..$.STA fpws| 00001f80 5f 31 2b 33 0d 0e 2e 10 4c 44 41 20 66 70 77 73 |_1+3....LDA fpws| 00001f90 5f 31 2b 32 0d 0e 38 10 53 42 43 20 66 70 77 73 |_1+2..8.SBC fpws| 00001fa0 5f 32 2b 32 0d 0e 42 10 53 54 41 20 66 70 77 73 |_2+2..B.STA fpws| 00001fb0 5f 31 2b 32 0d 0e 4c 10 4c 44 41 20 66 70 77 73 |_1+2..L.LDA fpws| 00001fc0 5f 31 2b 31 0d 0e 56 10 53 42 43 20 66 70 77 73 |_1+1..V.SBC fpws| 00001fd0 5f 32 2b 31 0d 0e 60 10 53 54 41 20 66 70 77 73 |_2+1..`.STA fpws| 00001fe0 5f 31 2b 31 0d 0e 6a 14 4c 44 41 20 66 70 77 73 |_1+1..j.LDA fpws| 00001ff0 5f 31 5f 6f 66 6c 6f 77 0d 0e 74 14 53 42 43 20 |_1_oflow..t.SBC | 00002000 66 70 77 73 5f 32 5f 6f 66 6c 6f 77 0d 0e 7e 14 |fpws_2_oflow..~.| 00002010 53 54 41 20 66 70 77 73 5f 31 5f 6f 66 6c 6f 77 |STA fpws_1_oflow| 00002020 0d 0e 88 05 20 0d 0e 92 07 52 54 53 0d 0e 9c 05 |.... ....RTS....| 00002030 20 0d 0e a6 15 2e 6e 65 67 5f 63 6f 6e 76 65 72 | .....neg_conver| 00002040 74 5f 62 61 63 6b 0d 0e b0 05 20 0d 0e ba 45 5c |t_back.... ...E\| 00002050 20 20 54 68 69 73 20 72 6f 75 74 69 6e 65 20 63 | This routine c| 00002060 6f 6e 76 65 72 74 73 20 61 6e 79 20 32 27 73 20 |onverts any 2's | 00002070 63 6f 6d 70 6c 65 6d 65 6e 74 20 72 65 73 75 6c |complement resul| 00002080 74 20 69 6e 74 6f 20 66 70 20 66 6f 72 6d 61 74 |t into fp format| 00002090 0d 0e c4 05 20 0d 0e ce 14 4c 44 41 20 66 70 77 |.... ....LDA fpw| 000020a0 73 5f 31 5f 6f 66 6c 6f 77 0d 0e d8 0f 42 50 4c |s_1_oflow....BPL| 000020b0 20 72 65 73 5f 70 6f 73 0d 0e e2 05 20 0d 0e ec | res_pos.... ...| 000020c0 1a 4a 53 52 20 63 6f 6e 76 65 72 74 5f 73 69 67 |.JSR convert_sig| 000020d0 6e 5f 66 70 77 73 31 0d 0e f6 0c 4c 44 41 20 23 |n_fpws1....LDA #| 000020e0 26 38 30 0d 0f 00 13 53 54 41 20 66 70 77 73 5f |&80....STA fpws_| 000020f0 31 5f 73 69 67 6e 0d 0f 0a 07 52 54 53 0d 0f 14 |1_sign....RTS...| 00002100 05 20 0d 0f 1e 0c 2e 72 65 73 5f 70 6f 73 0d 0f |. .....res_pos..| 00002110 28 05 20 0d 0f 32 0a 4c 44 41 20 23 30 0d 0f 3c |(. ..2.LDA #0..<| 00002120 13 53 54 41 20 66 70 77 73 5f 31 5f 73 69 67 6e |.STA fpws_1_sign| 00002130 0d 0f 46 05 20 0d 0f 50 07 52 54 53 0d 0f 5a 05 |..F. ..P.RTS..Z.| 00002140 20 0d 0f 64 10 2e 72 65 6e 6f 72 6d 61 6c 69 73 | ..d..renormalis| 00002150 65 0d 0f 6e 05 20 0d 0f 78 43 5c 20 54 68 69 73 |e..n. ..xC\ This| 00002160 20 72 6f 75 74 69 6e 65 20 6d 6f 64 69 66 69 65 | routine modifie| 00002170 73 20 74 68 65 20 6d 61 6e 74 69 73 73 61 20 61 |s the mantissa a| 00002180 6e 64 20 65 78 70 6f 6e 65 6e 74 20 6f 66 20 74 |nd exponent of t| 00002190 68 65 20 72 65 73 75 6c 74 0d 0f 82 2c 5c 20 54 |he result...,\ T| 000021a0 6f 20 70 72 6f 64 75 63 65 20 61 20 6e 6f 72 6d |o produce a norm| 000021b0 61 6c 69 73 65 64 20 66 6f 72 6d 61 74 20 6e 75 |alised format nu| 000021c0 6d 62 65 72 2e 0d 0f 8c 05 20 0d 0f 96 14 4c 44 |mber..... ....LD| 000021d0 41 20 66 70 77 73 5f 31 5f 6f 66 6c 6f 77 0d 0f |A fpws_1_oflow..| 000021e0 a0 4b 42 4e 45 20 73 68 69 66 74 5f 72 69 67 68 |.KBNE shift_righ| 000021f0 74 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 |t \ | 00002200 49 66 20 6f 76 65 72 66 6c 6f 77 20 69 73 20 3e |If overflow is >| 00002210 30 20 77 65 20 73 68 69 66 74 20 6d 61 6e 74 69 |0 we shift manti| 00002220 73 73 61 20 72 69 67 68 74 0d 0f aa 05 20 0d 0f |ssa right.... ..| 00002230 b4 46 4c 44 41 20 66 70 77 73 5f 31 2b 31 20 20 |.FLDA fpws_1+1 | 00002240 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 | \ | 00002250 54 6f 70 20 62 79 74 65 20 6f 66 20 6d 61 6e 74 |Top byte of mant| 00002260 69 73 73 61 20 69 73 20 73 68 69 66 74 65 64 20 |issa is shifted | 00002270 6c 65 66 74 0d 0f be 41 42 4d 49 20 6e 6f 72 6d |left...ABMI norm| 00002280 61 6c 69 73 65 64 20 20 20 20 20 20 20 20 20 20 |alised | 00002290 20 20 20 20 5c 20 75 6e 74 69 6c 20 74 6f 70 20 | \ until top | 000022a0 62 69 74 20 69 73 20 73 65 74 20 28 69 2e 65 2e |bit is set (i.e.| 000022b0 20 2d 76 65 29 0d 0f c8 05 20 0d 0f d2 14 2e 73 | -ve).... .....s| 000022c0 68 69 66 74 5f 6c 65 66 74 5f 6c 6f 6f 70 0d 0f |hift_left_loop..| 000022d0 dc 05 20 0d 0f e6 37 44 45 43 20 66 70 77 73 5f |.. ...7DEC fpws_| 000022e0 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |1 | 000022f0 20 20 20 5c 20 44 65 63 72 65 61 73 65 20 74 68 | \ Decrease th| 00002300 65 20 65 78 70 6f 6e 65 6e 74 0d 0f f0 43 41 53 |e exponent...CAS| 00002310 4c 20 66 70 77 73 5f 31 2b 34 20 20 20 20 20 20 |L fpws_1+4 | 00002320 20 20 20 20 20 20 20 20 20 20 5c 20 53 68 69 66 | \ Shif| 00002330 74 20 6d 61 6e 74 69 73 73 61 20 6c 65 66 74 20 |t mantissa left | 00002340 74 6f 20 63 6f 6d 70 65 6e 73 61 74 65 0d 0f fa |to compensate...| 00002350 10 52 4f 4c 20 66 70 77 73 5f 31 2b 33 0d 10 04 |.ROL fpws_1+3...| 00002360 10 52 4f 4c 20 66 70 77 73 5f 31 2b 32 0d 10 0e |.ROL fpws_1+2...| 00002370 10 52 4f 4c 20 66 70 77 73 5f 31 2b 31 0d 10 18 |.ROL fpws_1+1...| 00002380 05 20 0d 10 22 17 42 50 4c 20 73 68 69 66 74 5f |. ..".BPL shift_| 00002390 6c 65 66 74 5f 6c 6f 6f 70 0d 10 2c 05 20 0d 10 |left_loop..,. ..| 000023a0 36 35 52 54 53 20 20 20 20 20 20 20 20 20 20 20 |65RTS | 000023b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 | \ | 000023c0 4e 75 6d 62 65 72 20 72 65 6e 6f 72 6d 61 6c 69 |Number renormali| 000023d0 73 65 64 0d 10 40 05 20 0d 10 4a 10 2e 73 68 69 |sed..@. ..J..shi| 000023e0 66 74 5f 72 69 67 68 74 0d 10 54 05 20 0d 10 5e |ft_right..T. ..^| 000023f0 37 49 4e 43 20 66 70 77 73 5f 31 20 20 20 20 20 |7INC fpws_1 | 00002400 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 49 | \ I| 00002410 6e 63 72 65 61 73 65 20 74 68 65 20 65 78 70 6f |ncrease the expo| 00002420 6e 65 6e 74 0d 10 68 41 42 45 51 20 74 6f 6f 5f |nent..hABEQ too_| 00002430 62 69 67 20 20 20 20 20 20 20 20 20 20 20 20 20 |big | 00002440 20 20 20 20 5c 20 49 66 20 65 78 70 20 69 73 20 | \ If exp is | 00002450 7a 65 72 6f 20 77 65 20 68 61 76 65 20 6f 76 65 |zero we have ove| 00002460 72 66 6c 6f 77 0d 10 72 14 4c 53 52 20 66 70 77 |rflow..r.LSR fpw| 00002470 73 5f 31 5f 6f 66 6c 6f 77 0d 10 7c 44 52 4f 52 |s_1_oflow..|DROR| 00002480 20 66 70 77 73 5f 31 2b 31 20 20 20 20 20 20 20 | fpws_1+1 | 00002490 20 20 20 20 20 20 20 20 20 5c 20 53 68 69 66 74 | \ Shift| 000024a0 20 6d 61 6e 74 69 73 73 61 20 72 69 67 68 74 20 | mantissa right | 000024b0 74 6f 20 63 6f 6d 70 65 6e 73 61 74 65 0d 10 86 |to compensate...| 000024c0 10 52 4f 52 20 66 70 77 73 5f 31 2b 32 0d 10 90 |.ROR fpws_1+2...| 000024d0 10 52 4f 52 20 66 70 77 73 5f 31 2b 33 0d 10 9a |.ROR fpws_1+3...| 000024e0 10 52 4f 52 20 66 70 77 73 5f 31 2b 34 0d 10 a4 |.ROR fpws_1+4...| 000024f0 05 20 0d 10 ae 14 4c 44 41 20 66 70 77 73 5f 31 |. ....LDA fpws_1| 00002500 5f 6f 66 6c 6f 77 0d 10 b8 13 42 4e 45 20 73 68 |_oflow....BNE sh| 00002510 69 66 74 5f 72 69 67 68 74 0d 10 c2 05 20 0d 10 |ift_right.... ..| 00002520 cc 0f 2e 6e 6f 72 6d 61 6c 69 73 65 64 0d 10 d6 |...normalised...| 00002530 05 20 0d 10 e0 07 52 54 53 0d 10 ea 05 20 0d 10 |. ....RTS.... ..| 00002540 f4 15 2e 72 65 70 6c 61 63 65 5f 73 69 67 6e 5f |...replace_sign_| 00002550 62 69 74 0d 10 fe 05 20 0d 11 08 07 43 4c 43 0d |bit.... ....CLC.| 00002560 11 12 10 4c 44 41 20 66 70 77 73 5f 31 2b 31 0d |...LDA fpws_1+1.| 00002570 11 1c 0a 80 20 23 26 37 46 0d 11 26 13 41 44 43 |.... #&7F..&.ADC| 00002580 20 66 70 77 73 5f 31 5f 73 69 67 6e 0d 11 30 42 | fpws_1_sign..0B| 00002590 53 54 41 20 66 70 77 73 5f 31 2b 31 20 20 20 20 |STA fpws_1+1 | 000025a0 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 49 66 | \ If| 000025b0 20 2b 76 65 20 63 6c 65 61 72 20 74 6f 70 20 62 | +ve clear top b| 000025c0 69 74 20 6f 66 20 6d 61 6e 74 69 73 73 61 0d 11 |it of mantissa..| 000025d0 3a 05 20 0d 11 44 07 52 54 53 0d 11 4e 05 20 0d |:. ..D.RTS..N. .| 000025e0 11 58 0c 2e 74 6f 6f 5f 62 69 67 0d 11 62 05 20 |.X..too_big..b. | 000025f0 0d 11 6c 2d 5c 20 20 54 68 69 73 20 69 73 20 61 |..l-\ This is a| 00002600 6e 20 65 72 72 6f 72 20 63 6f 6e 64 69 74 69 6f |n error conditio| 00002610 6e 20 2d 20 6e 75 6d 62 65 72 20 32 30 0d 11 76 |n - number 20..v| 00002620 05 20 0d 11 80 07 42 52 4b 0d 11 8a 12 4f 50 54 |. ....BRK....OPT| 00002630 20 20 a4 45 51 55 42 28 32 30 29 0d 11 94 35 4f | .EQUB(20)...5O| 00002640 50 54 20 20 a4 45 51 55 53 28 22 52 65 73 75 6c |PT .EQUS("Resul| 00002650 74 20 6f 66 20 6d 75 6c 74 69 70 6c 69 63 61 74 |t of multiplicat| 00002660 69 6f 6e 20 69 73 20 74 6f 6f 20 62 69 67 22 29 |ion is too big")| 00002670 0d 11 9e 11 4f 50 54 20 20 a4 45 51 55 42 28 30 |....OPT .EQUB(0| 00002680 29 0d 11 a8 05 20 0d 11 b2 05 5d 0d 11 bc 05 ed |).... ....].....| 00002690 0d 11 c6 05 20 0d 11 d0 0b d6 20 63 6f 64 65 25 |.... ..... code%| 000026a0 0d 11 da 05 20 0d 11 e4 10 f1 22 52 65 73 75 6c |.... ....."Resul| 000026b0 74 73 3a 22 27 0d 11 ee 2c f1 20 22 41 64 64 69 |ts:"'...,. "Addi| 000026c0 74 69 6f 6e 20 28 63 6f 64 65 29 20 69 73 20 20 |tion (code) is | 000026d0 22 3b a4 66 70 28 72 65 73 75 6c 74 5f 61 64 64 |";.fp(result_add| 000026e0 29 0d 11 f8 24 f1 20 22 41 64 64 69 74 69 6f 6e |)...$. "Addition| 000026f0 20 28 42 41 53 49 43 29 20 69 73 20 22 3b 66 70 | (BASIC) is ";fp| 00002700 31 2b 66 70 32 0d 12 02 05 20 0d 12 0c 2f f1 20 |1+fp2.... .../. | 00002710 22 53 75 62 74 72 61 63 74 69 6f 6e 20 28 63 6f |"Subtraction (co| 00002720 64 65 29 20 69 73 20 20 22 3b a4 66 70 28 72 65 |de) is ";.fp(re| 00002730 73 75 6c 74 5f 73 75 62 29 0d 12 16 27 f1 20 22 |sult_sub)...'. "| 00002740 53 75 62 74 72 61 63 74 69 6f 6e 20 28 42 41 53 |Subtraction (BAS| 00002750 49 43 29 20 69 73 20 22 3b 66 70 31 2d 66 70 32 |IC) is ";fp1-fp2| 00002760 0d 12 20 05 20 0d 12 2a 05 e0 0d 12 34 05 20 0d |.. . ..*....4. .| 00002770 12 3e 1b 2a 2a 2a 2a 20 45 51 55 61 74 65 20 61 |.>.**** EQUate a| 00002780 20 42 79 74 65 20 2a 2a 2a 2a 0d 12 48 0f dd 20 | Byte ****..H.. | 00002790 a4 45 51 55 42 28 4e 25 29 0d 12 52 10 3f 50 25 |.EQUB(N%)..R.?P%| 000027a0 3d 4e 25 20 83 20 32 35 36 0d 12 5c 1e e7 20 28 |=N% . 256..\.. (| 000027b0 70 61 73 73 25 20 80 20 33 29 20 3d 20 33 20 8c |pass% . 3) = 3 .| 000027c0 20 f1 20 7e 3f 50 25 0d 12 66 0b 50 25 3d 50 25 | . ~?P%..f.P%=P%| 000027d0 2b 31 0d 12 70 0a 3d 70 61 73 73 25 0d 12 7a 05 |+1..p.=pass%..z.| 000027e0 20 0d 12 84 1d 2a 2a 2a 2a 20 45 51 55 61 74 65 | ....**** EQUate| 000027f0 20 61 20 53 74 72 69 6e 67 20 2a 2a 2a 2a 0d 12 | a String ****..| 00002800 8e 0f dd 20 a4 45 51 55 53 28 4e 24 29 0d 12 98 |... .EQUS(N$)...| 00002810 08 ea 20 4e 25 0d 12 a2 08 fe 20 34 30 0d 12 ac |.. N%..... 40...| 00002820 12 e3 20 4e 25 3d 31 20 b8 20 a9 28 4e 24 29 0d |.. N%=1 . .(N$).| 00002830 12 b6 13 4b 25 3d 97 28 c1 4e 24 2c 4e 25 2c 31 |...K%=.(.N$,N%,1| 00002840 29 29 0d 12 c0 10 50 25 3f 28 4e 25 2d 31 29 3d |))....P%?(N%-1)=| 00002850 4b 25 0d 12 ca 25 e7 20 28 70 61 73 73 25 20 80 |K%...%. (pass% .| 00002860 20 33 29 20 3d 20 33 20 8c 20 f1 20 7e 50 25 3f | 3) = 3 . . ~P%?| 00002870 28 4e 25 2d 31 29 3b 0d 12 d4 05 ed 0d 12 de 19 |(N%-1);.........| 00002880 e7 20 28 70 61 73 73 25 20 80 20 33 29 20 3d 20 |. (pass% . 3) = | 00002890 33 20 8c 20 f1 0d 12 e8 0f 50 25 3d 50 25 2b a9 |3 . .....P%=P%+.| 000028a0 28 4e 24 29 0d 12 f2 07 fe 20 30 0d 12 fc 0a 3d |(N$)..... 0....=| 000028b0 70 61 73 73 25 0d 13 06 05 20 0d 13 10 28 2a 2a |pass%.... ...(**| 000028c0 2a 2a 20 45 51 55 61 74 65 20 61 20 73 65 63 74 |** EQUate a sect| 000028d0 69 6f 6e 20 6f 66 20 4d 65 6d 6f 72 79 20 2a 2a |ion of Memory **| 000028e0 2a 2a 0d 13 1a 1a dd 20 a4 45 51 55 4d 28 6e 75 |**..... .EQUM(nu| 000028f0 6d 62 65 72 25 2c 62 79 74 65 25 29 0d 13 24 08 |mber%,byte%)..$.| 00002900 ea 20 4e 25 0d 13 2e 08 fe 20 34 30 0d 13 38 16 |. N%..... 40..8.| 00002910 e3 20 4e 25 3d 30 20 b8 20 6e 75 6d 62 65 72 25 |. N%=0 . number%| 00002920 2d 31 0d 13 42 0f 50 25 3f 4e 25 3d 62 79 74 65 |-1..B.P%?N%=byte| 00002930 25 0d 13 4c 21 e7 20 28 70 61 73 73 25 20 80 20 |%..L!. (pass% . | 00002940 33 29 20 3d 20 33 20 8c 20 f1 20 7e 50 25 3f 4e |3) = 3 . . ~P%?N| 00002950 25 3b 0d 13 56 05 ed 0d 13 60 19 e7 20 28 70 61 |%;..V....`.. (pa| 00002960 73 73 25 20 80 20 33 29 20 3d 20 33 20 8c 20 f1 |ss% . 3) = 3 . .| 00002970 0d 13 6a 11 50 25 3d 50 25 2b 6e 75 6d 62 65 72 |..j.P%=P%+number| 00002980 25 0d 13 74 07 fe 20 30 0d 13 7e 0a 3d 70 61 73 |%..t.. 0..~.=pas| 00002990 73 25 0d 13 88 05 20 0d 13 92 2c 2a 2a 2a 2a 20 |s%.... ...,**** | 000029a0 45 51 55 61 74 65 20 61 20 66 6c 6f 61 74 69 6e |EQUate a floatin| 000029b0 67 20 70 6f 69 6e 74 20 6e 75 6d 62 65 72 20 2a |g point number *| 000029c0 2a 2a 2a 0d 13 9c 19 57 65 20 75 73 65 20 74 68 |***....We use th| 000029d0 65 20 76 61 72 69 61 62 6c 65 20 60 0d 13 a6 2b |e variable `...+| 000029e0 74 6f 20 67 61 69 6e 20 61 63 63 65 73 73 20 74 |to gain access t| 000029f0 6f 20 42 41 53 49 43 27 73 20 66 70 20 63 6f 6e |o BASIC's fp con| 00002a00 76 65 72 73 69 6f 6e 0d 13 b0 2a 72 6f 75 74 69 |version...*routi| 00002a10 6e 65 73 2e 20 4e 6f 20 6f 74 68 65 72 20 76 61 |nes. No other va| 00002a20 72 69 61 62 6c 65 73 20 62 65 67 69 6e 6e 69 6e |riables beginnin| 00002a30 67 0d 13 ba 1a 77 69 74 68 20 60 20 63 61 6e 20 |g....with ` can | 00002a40 62 65 20 64 65 66 69 6e 65 64 2e 0d 13 c4 0e dd |be defined......| 00002a50 20 a4 45 51 55 46 28 60 29 0d 13 ce 0c ea 20 4d | .EQUF(`)..... M| 00002a60 25 2c 20 4e 25 0d 13 d8 08 fe 20 34 30 0d 13 e2 |%, N%..... 40...| 00002a70 1a 4d 25 20 3d 20 33 2b 28 21 26 34 43 30 20 80 |.M% = 3+(!&4C0 .| 00002a80 20 26 46 46 46 46 29 0d 13 ec 0e e3 20 4e 25 3d | &FFFF)..... N%=| 00002a90 30 20 b8 20 34 0d 13 f6 0f 50 25 3f 4e 25 3d 4d |0 . 4....P%?N%=M| 00002aa0 25 3f 4e 25 0d 14 00 21 e7 20 28 70 61 73 73 25 |%?N%...!. (pass%| 00002ab0 20 80 20 33 29 20 3d 20 33 20 8c 20 f1 20 7e 50 | . 3) = 3 . . ~P| 00002ac0 25 3f 4e 25 3b 0d 14 0a 05 ed 0d 14 14 19 e7 20 |%?N%;.......... | 00002ad0 28 70 61 73 73 25 20 80 20 33 29 20 3d 20 33 20 |(pass% . 3) = 3 | 00002ae0 8c 20 f1 0d 14 1e 0b 50 25 3d 50 25 2b 35 0d 14 |. .....P%=P%+5..| 00002af0 28 07 fe 20 30 0d 14 32 0a 3d 70 61 73 73 25 0d |(.. 0..2.=pass%.| 00002b00 14 3c 05 20 0d 14 46 18 2a 2a 2a 2a 20 52 65 76 |.<. ..F.**** Rev| 00002b10 65 72 73 65 20 46 50 20 2a 2a 2a 2a 0d 14 50 1e |erse FP ****..P.| 00002b20 50 75 74 73 20 66 70 20 6e 75 6d 62 65 72 20 66 |Puts fp number f| 00002b30 72 6f 6d 20 6d 65 6d 6f 72 79 0d 14 5a 1b 69 6e |rom memory..Z.in| 00002b40 74 6f 20 76 61 72 69 61 62 6c 65 20 60 20 28 50 |to variable ` (P| 00002b50 4f 55 4e 44 29 0d 14 64 0f dd 20 a4 66 70 28 6d |OUND)..d.. .fp(m| 00002b60 65 6d 25 29 0d 14 6e 0c ea 20 4d 25 2c 20 4e 25 |em%)..n.. M%, N%| 00002b70 0d 14 78 07 60 3d 30 0d 14 82 1a 4d 25 20 3d 20 |..x.`=0....M% = | 00002b80 33 2b 28 21 26 34 43 30 20 80 20 26 46 46 46 46 |3+(!&4C0 . &FFFF| 00002b90 29 0d 14 8c 0e e3 20 4e 25 3d 30 20 b8 20 34 0d |)..... N%=0 . 4.| 00002ba0 14 96 11 4d 25 3f 4e 25 3d 6d 65 6d 25 3f 4e 25 |...M%?N%=mem%?N%| 00002bb0 0d 14 a0 05 ed 0d 14 aa 06 3d 60 0d ff |.........=`..| 00002bbd