LINPRT ... that's helluva lot of code just to print an unsigned 16-bit int.

The only good news is that it is built-into ROM.

Usage:

LDA #$12

LDX #$34

JMP $ED24

Output:

4660

NOTE: Stack $100 .. $1104 is used as output buffer.

Requires:

* $E000 Basic Cold Start or

* $E003 Basic Warm Start

must be called first.

Call Tree:

LINPRT

FLOAT.2

NORMALIZE.FAC.1

FOUT

STROUT

STRLIT

FREFAC

OUTDO

Partial disassembly ...

http://www.txbobsc.com/scsc/scdocumentor/ED0A.html

http://jamtronix.com/files/applesoft.html

1130 *--------------------------------

1140 * PRINT A,X AS DECIMAL INTEGER

1150 *--------------------------------

ED24- 85 9E 1160 LINPRT STA FAC+1 PRINT A,X IN DECIMAL

ED26- 86 9F 1170 STX FAC+2

ED28- A2 90 1180 LDX #$90 EXPONENT = 2^16

ED2A- 38 1190 SEC CONVERT UNSIGNED

ED2B- 20 A0 EB 1200 JSR FLOAT.2 CONVERT LINE # TO FP

1210 *--------------------------------

1220 * CONVERT (FAC) TO STRING, AND PRINT IT

1230 *--------------------------------

1240 PRINT.FAC

ED2E- 20 34 ED 1250 JSR FOUT CONVERT (FAC) TO STRING AT STACK

1260 *--------------------------------

1270 * PRINT STRING STARTING AT Y,A

1280 *--------------------------------

1290 GO.STROUT

ED31- 4C 3A DB 1300 JMP STROUT PRINT STRING AT A,Y

1310 *--------------------------------

1320 * CONVERT (FAC) TO STRING STARTING AT STACK

1330 * RETURN WITH (Y,A) POINTING AT STRING

1340 *--------------------------------

ED34- A0 01 1350 FOUT LDY #1 NORMAL ENTRY PUTS STRING AT STACK...

1360 *--------------------------------

1370 * "STR$" FUNCTION ENTERS HERE, WITH (Y)=0

1380 * SO THAT RESULT STRING STARTS AT STACK-1

1390 * (THIS IS USED AS A FLAG)

1400 *--------------------------------

ED36- A9 2D 1410 FOUT.1 LDA #'-' IN CASE VALUE NEGATIVE

ED38- 88 1420 DEY BACK UP PNTR

ED39- 24 A2 1430 BIT FAC.SIGN

ED3B- 10 04 1440 BPL .1 VALUE IS +

ED3D- C8 1450 INY VALUE IS -

ED3E- 99 FF 00 1460 STA STACK-1,Y EMIT "-"

ED41- 85 A2 1470 .1 STA FAC.SIGN MAKE FAC.SIGN POSITIVE ($2D)

ED43- 84 AD 1480 STY STRNG2 SAVE STRING PNTR

ED45- C8 1490 INY

ED46- A9 30 1500 LDA #'0' IN CASE (FAC)=0

ED48- A6 9D 1510 LDX FAC NUMBER=0?

ED4A- D0 03 1520 BNE .2 NO, (FAC) NOT ZERO

ED4C- 4C 57 EE 1530 JMP FOUT.4 YES, FINISHED

1540 *--------------------------------

ED4F- A9 00 1550 .2 LDA #0 STARTING VALUE FOR TMPEXP

ED51- E0 80 1560 CPX #$80 ANY INTEGER PART?

ED53- F0 02 1570 BEQ .3 NO, BTWN .5 AND .999999999

ED55- B0 09 1580 BCS .4 YES

1590 *--------------------------------

ED57- A9 14 1600 .3 LDA #CON.BILLION MULTIPLY BY 1E9

ED59- A0 ED 1610 LDY /CON.BILLION TO GIVE ADJUSTMENT A HEAD START

ED5B- 20 7F E9 1620 JSR FMULT

ED5E- A9 F7 1630 LDA #-9 EXPONENT ADJUSTMENT

ED60- 85 99 1640 .4 STA TMPEXP 0 OR -9

1650 *--------------------------------

1660 * ADJUST UNTIL 1E8 <= (FAC) <1E9

1670 *--------------------------------

ED62- A9 0F 1680 .5 LDA #CON.999999999

ED64- A0 ED 1690 LDY /CON.999999999

ED66- 20 B2 EB 1700 JSR FCOMP COMPARE TO 1E9-1

ED69- F0 1E 1710 BEQ .10 (FAC) = 1E9-1

ED6B- 10 12 1720 BPL .8 TOO LARGE, DIVIDE BY TEN

ED6D- A9 0A 1730 .6 LDA #CON.99999999.9 COMPARE TO 1E8-.1

ED6F- A0 ED 1740 LDY /CON.99999999.9

ED71- 20 B2 EB 1750 JSR FCOMP COMPARE TO 1E8-.1

ED74- F0 02 1760 BEQ .7 (FAC) = 1E8-.1

ED76- 10 0E 1770 BPL .9 IN RANGE, ADJUSTMENT FINISHED

ED78- 20 39 EA 1780 .7 JSR MUL10 TOO SMALL, MULTIPLY BY TEN

ED7B- C6 99 1790 DEC TMPEXP KEEP TRACK OF MULTIPLIES

ED7D- D0 EE 1800 BNE .6 ...ALWAYS

ED7F- 20 55 EA 1810 .8 JSR DIV10 TOO LARGE, DIVIDE BY TEN

ED82- E6 99 1820 INC TMPEXP KEEP TRACK OF DIVISIONS

ED84- D0 DC 1830 BNE .5 ...ALWAYS

1840 *--------------------------------

ED86- 20 A0 E7 1850 .9 JSR FADDH ROUND ADJUSTED RESULT

ED89- 20 F2 EB 1860 .10 JSR QINT CONVERT ADJUSTED VALUE TO 32-BIT INTEGER

1870 *--------------------------------

1880 * FAC+1...FAC+4 IS NOW IN INTEGER FORM

1890 * WITH POWER OF TEN ADJUSTMENT IN TMPEXP

1900 *

1910 * IF -10 < TMPEXP > 1, PRINT IN DECIMAL FORM

1920 * OTHERWISE, PRINT IN EXPONENTIAL FORM

1930 *--------------------------------

ED8C- A2 01 1940 FOUT.2 LDX #1 ASSUME 1 DIGIT BEFORE "."

ED8E- A5 99 1950 LDA TMPEXP CHECK RANGE

ED90- 18 1960 CLC

ED91- 69 0A 1970 ADC #10

ED93- 30 09 1980 BMI .1 < .01, USE EXPONENTIAL FORM

ED95- C9 0B 1990 CMP #11

ED97- B0 06 2000 BCS .2 >= 1E10, USE EXPONENTIAL FORM

ED99- 69 FF 2010 ADC #$FF LESS 1 GIVES INDEX FOR "."

ED9B- AA 2020 TAX

ED9C- A9 02 2030 LDA #2 SET REMAINING EXPONENT = 0

ED9E- 38 2040 .1 SEC COMPUTE REMAINING EXPONENT

ED9F- E9 02 2050 .2 SBC #2

EDA1- 85 9A 2060 STA EXPON VALUE FOR "E+XX" OR "E-XX"

EDA3- 86 99 2070 STX TMPEXP INDEX FOR DECIMAL POINT

EDA5- 8A 2080 TXA SEE IF "." COMES FIRST

EDA6- F0 02 2090 BEQ .3 YES

EDA8- 10 13 2100 BPL .5 NO, LATER

EDAA- A4 AD 2110 .3 LDY STRNG2 GET INDEX INTO STRING BEING BUILT

EDAC- A9 2E 2120 LDA #'.' STORE A DECIMAL POINT

EDAE- C8 2130 INY

EDAF- 99 FF 00 2140 STA STACK-1,Y

EDB2- 8A 2150 TXA SEE IF NEED ".0"

EDB3- F0 06 2160 BEQ .4 NO

EDB5- A9 30 2170 LDA #'0' YES, STORE "0"

EDB7- C8 2180 INY

EDB8- 99 FF 00 2190 STA STACK-1,Y

EDBB- 84 AD 2200 .4 STY STRNG2 SAVE OUTPUT INDEX AGAIN

2210 *--------------------------------

2220 * NOW DIVIDE BY POWERS OF TEN TO GET SUCCESSIVE DIGITS

2230 *--------------------------------

EDBD- A0 00 2240 .5 LDY #0 INDEX TO TABLE OF POWERS OF TEN

EDBF- A2 80 2250 LDX #$80 STARTING VALUE FOR DIGIT WITH DIRECTION

EDC1- A5 A1 2260 .6 LDA FAC+4 START BY ADDING -100000000 UNTIL

EDC3- 18 2270 CLC OVERSHOOT. THEN ADD +10000000,

EDC4- 79 6C EE 2280 ADC DECTBL+3,Y THEN ADD -1000000, THEN ADD

EDC7- 85 A1 2290 STA FAC+4 +100000, AND SO ON.

EDC9- A5 A0 2300 LDA FAC+3 THE # OF TIMES EACH POWER IS ADDED

EDCB- 79 6B EE 2310 ADC DECTBL+2,Y IS 1 MORE THAN CORRESPONDING DIGIT

EDCE- 85 A0 2320 STA FAC+3

EDD0- A5 9F 2330 LDA FAC+2

EDD2- 79 6A EE 2340 ADC DECTBL+1,Y

EDD5- 85 9F 2350 STA FAC+2

EDD7- A5 9E 2360 LDA FAC+1

EDD9- 79 69 EE 2370 ADC DECTBL,Y

EDDC- 85 9E 2380 STA FAC+1

EDDE- E8 2390 INX COUNT THE ADD

EDDF- B0 04 2400 BCS .7 IF C=1 AND X NEGATIVE, KEEP ADDING

EDE1- 10 DE 2410 BPL .6 IF C=0 AND X POSITIVE, KEEP ADDING

EDE3- 30 02 2420 BMI .8 IF C=0 AND X NEGATIVE, WE OVERSHOT

EDE5- 30 DA 2430 .7 BMI .6 IF C=1 AND X POSITIVE, WE OVERSHOT

EDE7- 8A 2440 .8 TXA OVERSHOT, SO MAKE X INTO A DIGIT

EDE8- 90 04 2450 BCC .9 HOW DEPENDS ON DIRECTION WE WERE GOING

EDEA- 49 FF 2460 EOR #$FF DIGIT = 9-X

EDEC- 69 0A 2470 ADC #10

EDEE- 69 2F 2480 .9 ADC #'0'-1 MAKE DIGIT INTO ASCII

EDF0- C8 2490 INY ADVANCE TO NEXT SMALLER POWER OF TEN

EDF1- C8 2500 INY

EDF2- C8 2510 INY

EDF3- C8 2520 INY

EDF4- 84 83 2530 STY VARPNT SAVE PNTR TO POWERS

EDF6- A4 AD 2540 LDY STRNG2 GET OUTPUT PNTR

EDF8- C8 2550 INY STORE THE DIGIT

EDF9- AA 2560 TAX SAVE DIGIT, HI-BIT IS DIRECTION

EDFA- 29 7F 2570 AND #$7F MAKE SURE $30...$39 FOR STRING

EDFC- 99 FF 00 2580 STA STACK-1,Y

EDFF- C6 99 2590 DEC TMPEXP COUNT THE DIGIT

EE01- D0 06 2600 BNE .10 NOT TIME FOR "." YET

EE03- A9 2E 2610 LDA #'.' TIME, SO STORE THE DECIMAL POINT

EE05- C8 2620 INY

EE06- 99 FF 00 2630 STA STACK-1,Y

EE09- 84 AD 2640 .10 STY STRNG2 SAVE OUTPUT PNTR AGAIN

EE0B- A4 83 2650 LDY VARPNT GET PNTR TO POWERS

EE0D- 8A 2660 TXA GET DIGIT WITH HI-BIT = DIRECTION

EE0E- 49 FF 2670 EOR #$FF CHANGE DIRECTION

EE10- 29 80 2680 AND #$80 $00 IF ADDING, $80 IF SUBTRACTING

EE12- AA 2690 TAX

EE13- C0 24 2700 CPY #DECTBL.END-DECTBL

EE15- D0 AA 2710 BNE .6 NOT FINISHED YET

2720 *--------------------------------

2730 * NINE DIGITS HAVE BEEN STORED IN STRING. NOW LOOK

2740 * BACK AND LOP OFF TRAILING ZEROES AND A TRAILING

2750 * DECIMAL POINT.

2760 *--------------------------------

EE17- A4 AD 2770 FOUT.3 LDY STRNG2 POINTS AT LAST STORED CHAR

EE19- B9 FF 00 2780 .1 LDA STACK-1,Y SEE IF LOPPABLE

EE1C- 88 2790 DEY

EE1D- C9 30 2800 CMP #'0' SUPPRESS TRAILING ZEROES

EE1F- F0 F8 2810 BEQ .1 YES, KEEP LOOPING

EE21- C9 2E 2820 CMP #'.' SUPPRESS TRAILING DECIMAL POINT

EE23- F0 01 2830 BEQ .2 ".", SO WRITE OVER IT

EE25- C8 2840 INY NOT ".", SO INCLUDE IN STRING AGAIN

EE26- A9 2B 2850 .2 LDA #'+' PREPARE FOR POSITIVE EXPONENT "E+XX"

EE28- A6 9A 2860 LDX EXPON SEE IF ANY E-VALUE

EE2A- F0 2E 2870 BEQ FOUT.5 NO, JUST MARK END OF STRING

EE2C- 10 08 2880 BPL .3 YES, AND IT IS POSITIVE

EE2E- A9 00 2890 LDA #0 YES, AND IT IS NEGATIVE

EE30- 38 2900 SEC COMPLEMENT THE VALUE

EE31- E5 9A 2910 SBC EXPON

EE33- AA 2920 TAX GET MAGNITUDE IN X

EE34- A9 2D 2930 LDA #'-' E SIGN

EE36- 99 01 01 2940 .3 STA STACK+1,Y STORE SIGN IN STRING

EE39- A9 45 2950 LDA #'E' STORE "E" IN STRING BEFORE SIGN

EE3B- 99 00 01 2960 STA STACK,Y

EE3E- 8A 2970 TXA EXPONENT MAGNITUDE IN A-REG

EE3F- A2 2F 2980 LDX #'0'-1 SEED FOR EXPONENT DIGIT

EE41- 38 2990 SEC CONVERT TO DECIMAL

EE42- E8 3000 .4 INX COUNT THE SUBTRACTION

EE43- E9 0A 3010 SBC #10 TEN'S DIGIT

EE45- B0 FB 3020 BCS .4 MORE TENS TO SUBTRACT

EE47- 69 3A 3030 ADC #'0'+10 CONVERT REMAINDER TO ONE'S DIGIT

EE49- 99 03 01 3040 STA STACK+3,Y STORE ONE'S DIGIT

EE4C- 8A 3050 TXA

EE4D- 99 02 01 3060 STA STACK+2,Y STORE TEN'S DIGIT

EE50- A9 00 3070 LDA #0 MARK END OF STRING WITH $00

EE52- 99 04 01 3080 STA STACK+4,Y

EE55- F0 08 3090 BEQ FOUT.6 ...ALWAYS

EE57- 99 FF 00 3100 FOUT.4 STA STACK-1,Y STORE "0" IN ASCII

EE5A- A9 00 3110 FOUT.5 LDA #0 STORE $00 ON END OF STRING

EE5C- 99 00 01 3120 STA STACK,Y

EE5F- A9 00 3130 FOUT.6 LDA #STACK POINT Y,A AT BEGINNING OF STRING

EE61- A0 01 3140 LDY /STACK (STR$ STARTED STRING AT STACK-1, BUT

EE63- 60 3150 RTS STR$ DOESN'T USE Y,A ANYWAY.)

3160 *--------------------------------

EE64- 80 00 00

EE67- 00 00 3170 CON.HALF .HS 8000000000 FP CONSTANT 0.5

3180 *--------------------------------

3190 * POWERS OF 10 FROM 1E8 DOWN TO 1,

3200 * AS 32-BIT INTEGERS, WITH ALTERNATING SIGNS

3210 *--------------------------------

EE69- FA 0A 1F

EE6C- 00 3220 DECTBL .HS FA0A1F00 -100000000

EE6D- 00 98 96

EE70- 80 3230 .HS 00989680 10000000

EE71- FF F0 BD

EE74- C0 3240 .HS FFF0BDC0 -1000000

EE75- 00 01 86

EE78- A0 3250 .HS 000186A0 100000

EE79- FF FF D8

EE7C- F0 3260 .HS FFFFD8F0 -10000

EE7D- 00 00 03

EE80- E8 3270 .HS 000003E8 1000

EE81- FF FF FF

EE84- 9C 3280 .HS FFFFFF9C -100

EE85- 00 00 00

EE88- 0A 3290 .HS 0000000A 10

EE89- FF FF FF

EE8C- FF 3300 .HS FFFFFFFF -1

3310 DECTBL.END

3320 *--------------------------------

... and STROUT ...

DB02- 60 1310 RTS.8 RTS

1690 *--------------------------------

1700 * PRINT STRING AT (Y,A)

DB3A- 20 E7 E3 1710 STROUT JSR STRLIT MAKE (Y,A) PRINTABLE

1720 *--------------------------------

1730 * PRINT STRING AT (FACMO,FACLO)

1740 *--------------------------------

DB3D- 20 00 E6 1750 STRPRT JSR FREFAC GET ADDRESS INTO INDEX, (A)=LENGTH

DB40- AA 1760 TAX USE X-REG FOR COUNTER

DB41- A0 00 1770 LDY #0 USE Y-REG FOR SCANNER

DB43- E8 1780 INX

DB44- CA 1790 .1 DEX

DB45- F0 BB 1800 BEQ RTS.8 FINISHED

DB47- B1 5E 1810 LDA (INDEX),Y NEXT CHAR FROM STRING

DB49- 20 5C DB 1820 JSR OUTDO PRINT THE CHAR

DB4C- C8 1830 INY

1840 * <<< NEXT THREE LINES ARE USELESS >>>

DB4D- C9 0D 1850 CMP #$0D WAS IT <RETURN>?

DB4F- D0 F3 1860 BNE .1 NO

DB51- 20 00 DB 1870 JSR NEGATE EOR #$FF WOULD DO IT, BUT WHY?

1880 * <<< ABOVE THREE LINES ARE USELESS >>>

DB54- 4C 44 DB 1890 JMP .1

1900 *--------------------------------

DB57- A9 20 1910 OUTSP LDA #' ' PRINT A SPACE

DB59- 2C 1920 .HS 2C SKIP OVER NEXT LINE

DB5A- A9 3F 1930 OUTQUES LDA #'?' PRINT QUESTION MARK

1940 *--------------------------------

1950 * PRINT CHAR FROM (A)

1960 *

1970 * NOTE: POKE 243,32 ($20 IN $F3) WILL CONVERT

1980 * OUTPUT TO LOWER CASE. THIS CAN BE CANCELLED

1990 * BY NORMAL, INVERSE, OR FLASH OR POKE 243,0.

2000 *--------------------------------

DB5C- 09 80 2010 OUTDO ORA #$80 PRINT (A)

DB5E- C9 A0 2020 CMP #$A0 CONTROL CHR?

DB60- 90 02 2030 BCC .1 SKIP IF SO

DB62- 05 F3 2040 ORA FLASH.BIT =$40 FOR FLASH, ELSE $00

DB64- 20 ED FD 2050 .1 JSR MON.COUT "AND"S WITH $3F (INVERSE), $7F (FLASH)

DB67- 29 7F 2060 AND #$7F

DB69- 48 2070 PHA

DB6A- A5 F1 2080 LDA SPEEDZ COMPLEMENT OF SPEED #

DB6C- 20 A8 FC 2090 JSR MON.WAIT SO SPEED=255 BECOMES (A)=1

DB6F- 68 2100 PLA

DB70- 60 2110 RTS

... and STRLIT ...

1300 *--------------------------------

1310 * BUILD A DESCRIPTOR FOR STRING STARTING AT Y,A

1320 * AND TERMINATED BY $00 OR QUOTATION MARK

1330 * RETURN WITH DESCRIPTOR IN A TEMPORARY

1340 * AND ADDRESS OF DESCRIPTOR IN FAC+3,4

1350 *--------------------------------

E3E7- A2 22 1360 STRLIT LDX #'"' SET UP LITERAL SCAN TO STOP ON

E3E9- 86 0D 1370 STX CHARAC QUOTATION MARK OR $00

E3EB- 86 0E 1380 STX ENDCHR

1390 *--------------------------------

1400 * BUILD A DESCRIPTOR FOR STRING STARTING AT Y,A

1410 * AND TERMINATED BY $00, (CHARAC), OR (ENDCHR)

1420 *

1430 * RETURN WITH DESCRIPTOR IN A TEMPORARY

1440 * AND ADDRESS OF DESCRIPTOR IN FAC+3,4

1450 *--------------------------------

E3ED- 85 AB 1460 STRLT2 STA STRNG1 SAVE ADDRESS OF STRING

E3EF- 84 AC 1470 STY STRNG1+1

E3F1- 85 9E 1480 STA FAC+1 ...AGAIN

E3F3- 84 9F 1490 STY FAC+2

E3F5- A0 FF 1500 LDY #$FF

E3F7- C8 1510 .1 INY FIND END OF STRING

E3F8- B1 AB 1520 LDA (STRNG1),Y NEXT STRING CHAR

E3FA- F0 0C 1530 BEQ .3 END OF STRING

E3FC- C5 0D 1540 CMP CHARAC ALTERNATE TERMINATOR # 1?

E3FE- F0 04 1550 BEQ .2 YES

E400- C5 0E 1560 CMP ENDCHR ALTERNATE TERMINATOR # 2?

E402- D0 F3 1570 BNE .1 NO, KEEP SCANNING

E404- C9 22 1580 .2 CMP #'"' IS STRING ENDED WITH QUOTE MARK?

E406- F0 01 1590 BEQ .4 YES, C=1 TO INCLUDE " IN STRING

E408- 18 1600 .3 CLC

E409- 84 9D 1610 .4 STY FAC SAVE LENGTH

E40B- 98 1620 TYA

E40C- 65 AB 1630 ADC STRNG1 COMPUTE ADDRESS OF END OF STRING

E40E- 85 AD 1640 STA STRNG2 (OF 00 BYTE, OR JUST AFTER ")

E410- A6 AC 1650 LDX STRNG1+1

E412- 90 01 1660 BCC .5

E414- E8 1670 INX

E415- 86 AE 1680 .5 STX STRNG2+1

E417- A5 AC 1690 LDA STRNG1+1 WHERE DOES THE STRING START?

E419- F0 04 1700 BEQ .6 PAGE 0, MUST BE FROM STR$ FUNCTION

E41B- C9 02 1710 CMP #2 PAGE 2?

E41D- D0 0B 1720 BNE PUTNEW NO, NOT PAGE 0 OR 2

E41F- 98 1730 .6 TYA LENGTH OF STRING

E420- 20 D5 E3 1740 JSR STRINI MAKE SPACE FOR STRING

E423- A6 AB 1750 LDX STRNG1

E425- A4 AC 1760 LDY STRNG1+1

E427- 20 E2 E5 1770 JSR MOVSTR MOVE IT IN

1780 *--------------------------------

1790 * STORE DESCRIPTOR IN TEMPORARY DESCRIPTOR STACK

1800 *

1810 * THE DESCRIPTOR IS NOW IN FAC, FAC+1, FAC+2

1820 * PUT ADDRESS OF TEMP DESCRIPTOR IN FAC+3,4

1830 *--------------------------------

E42A- A6 52 1840 PUTNEW LDX TEMPPT POINTER TO NEXT TEMP STRING SLOT

E42C- E0 5E 1850 CPX #TEMPST+9 MAX OF 3 TEMP STRINGS

E42E- D0 05 1860 BNE PUTEMP ROOM FOR ANOTHER ONE

E430- A2 BF 1870 LDX #ERR.FRMCPX TOO MANY, FORMULA TOO COMPLEX

E432- 4C 12 D4 1880 JERR JMP ERROR

1890 *--------------------------------

E435- A5 9D 1900 PUTEMP LDA FAC COPY TEMP DESCRIPTOR INTO TEMP STACK

E437- 95 00 1910 STA 0,X

E439- A5 9E 1920 LDA FAC+1

E43B- 95 01 1930 STA 1,X

E43D- A5 9F 1940 LDA FAC+2

E43F- 95 02 1950 STA 2,X

E441- A0 00 1960 LDY #0

E443- 86 A0 1970 STX FAC+3 ADDRESS OF TEMP DESCRIPTOR

E445- 84 A1 1980 STY FAC+4 IN Y,X AND FAC+3,4

E447- 88 1990 DEY Y=$FF

E448- 84 11 2000 STY VALTYP FLAG (FAC ) AS STRING

E44A- 86 53 2010 STX LASTPT INDEX OF LAST POINTER

E44C- E8 2020 INX UPDATE FOR NEXT TEMP ENTRY

E44D- E8 2030 INX

E44E- E8 2040 INX

E44F- 86 52 2050 STX TEMPPT

E451- 60 2060 RTS

... and FREFAC ...

1720 *--------------------------------

1730 * IF STRING DESCRIPTOR POINTED TO BY FAC+3,4 IS

1740 * A TEMPORARY STRING, RELEASE IT.

1750 *--------------------------------

E600- A5 A0 1760 FREFAC LDA FAC+3 GET DESCRIPTOR POINTER

E602- A4 A1 1770 LDY FAC+4

1780 *--------------------------------

1790 * IF STRING DESCRIPTOR WHOSE ADDRESS IS IN Y,A IS

1800 * A TEMPORARY STRING, RELEASE IT.

1810 *--------------------------------

E604- 85 5E 1820 FRETMP STA INDEX SAVE THE ADDRESS OF THE DESCRIPTOR

E606- 84 5F 1830 STY INDEX+1

E608- 20 35 E6 1840 JSR FRETMS FREE DESCRIPTOR IF IT IS TEMPORARY

E60B- 08 1850 PHP REMEMBER IF TEMP

E60C- A0 00 1860 LDY #0 POINT AT LENGTH OF STRING

E60E- B1 5E 1870 LDA (INDEX),Y

E610- 48 1880 PHA SAVE LENGTH ON STACK

E611- C8 1890 INY

E612- B1 5E 1900 LDA (INDEX),Y

E614- AA 1910 TAX GET ADDRESS OF STRING IN Y,X

E615- C8 1920 INY

E616- B1 5E 1930 LDA (INDEX),Y

E618- A8 1940 TAY

E619- 68 1950 PLA LENGTH IN A

E61A- 28 1960 PLP RETRIEVE STATUS, Z=1 IF TEMP

E61B- D0 13 1970 BNE .2 NOT A TEMPORARY STRING

E61D- C4 70 1980 CPY FRETOP+1 IS IT THE LOWEST STRING?

E61F- D0 0F 1990 BNE .2 NO

E621- E4 6F 2000 CPX FRETOP

E623- D0 0B 2010 BNE .2 NO

E625- 48 2020 PHA YES, PUSH LENGTH AGAIN

E626- 18 2030 CLC RECOVER THE SPACE USED BY

E627- 65 6F 2040 ADC FRETOP THE STRING

E629- 85 6F 2050 STA FRETOP

E62B- 90 02 2060 BCC .1

E62D- E6 70 2070 INC FRETOP+1

E62F- 68 2080 .1 PLA RETRIEVE LENGTH AGAIN

E630- 86 5E 2090 .2 STX INDEX ADDRESS OF STRING IN Y,X

E632- 84 5F 2100 STY INDEX+1 LENGTH OF STRING IN A-REG

E634- 60 2110 RTS

... and NORMALIZE.FAC.1 ...

1850 *--------------------------------

1860 * NORMALIZE VALUE IN FAC

1870 *--------------------------------

1880 NORMALIZE.FAC.1

E829- B0 03 1890 BCS NORMALIZE.FAC.2

E82B- 20 9E E8 1900 JSR COMPLEMENT.FAC

1910 *--------------------------------

1920 NORMALIZE.FAC.2

E82E- A0 00 1930 LDY #0 SHIFT UP SIGNIF DIGIT

E830- 98 1940 TYA START A=0, COUNT SHIFTS IN A-REG

E831- 18 1950 CLC

E832- A6 9E 1960 .1 LDX FAC+1 LOOK AT MOST SIGNIFICANT BYTE

E834- D0 4A 1970 BNE NORMALIZE.FAC.4 SOME 1-BITS HERE

E836- A6 9F 1980 LDX FAC+2 HI-BYTE OF MANTISSA STILL ZERO,

E838- 86 9E 1990 STX FAC+1 SO DO A FAST 8-BIT SHUFFLE

E83A- A6 A0 2000 LDX FAC+3

E83C- 86 9F 2010 STX FAC+2

E83E- A6 A1 2020 LDX FAC+4

E840- 86 A0 2030 STX FAC+3

E842- A6 AC 2040 LDX FAC.EXTENSION

E844- 86 A1 2050 STX FAC+4

E846- 84 AC 2060 STY FAC.EXTENSION ZERO EXTENSION BYTE

E848- 69 08 2070 ADC #8 BUMP SHIFT COUNT

E84A- C9 20 2080 CMP #32 DONE 4 TIMES YET?

E84C- D0 E4 2090 BNE .1 NO, STILL MIGHT BE SOME 1'S

2100 * YES, VALUE OF FAC IS ZERO

2110 *--------------------------------

2120 * SET FAC = 0

2130 * (ONLY NECESSARY TO ZERO EXPONENT AND SIGN CELLS)

2140 *--------------------------------

2150 ZERO.FAC

E84E- A9 00 2160 LDA #0

2170 *--------------------------------

2180 STA.IN.FAC.SIGN.AND.EXP

E850- 85 9D 2190 STA FAC

2200 *--------------------------------

2210 STA.IN.FAC.SIGN

E852- 85 A2 2220 STA FAC.SIGN

E854- 60 2230 RTS

... and FLOAT.2 ...

1520 *--------------------------------

1530 * FLOAT UNSIGNED VALUE IN FAC+1,2

1540 * (X) = EXPONENT

1550 * C=0 TO MAKE VALUE NEGATIVE

1560 * C=1 TO MAKE VALUE POSITIVE

1570 *--------------------------------

1580 FLOAT.2

EBA0- A9 00 1590 LDA #0 CLEAR LOWER 16-BITS OF MANTISSA

EBA2- 85 A1 1600 STA FAC+4

EBA4- 85 A0 1610 STA FAC+3

EBA6- 86 9D 1620 STX FAC STORE EXPONENT

EBA8- 85 AC 1630 STA FAC.EXTENSION CLEAR EXTENSION

EBAA- 85 A2 1640 STA FAC.SIGN MAKE SIGN POSITIVE

EBAC- 4C 29 E8 1650 JMP NORMALIZE.FAC.1 IF C=0, WILL NEGATE FAC