
 1000  *SAVE S.BINDEC
 1010  *--------------------------------
 1020  XL     .EQ $00
 1030  XH     .EQ $01
 1040  SL     .EQ $10
 1050  SH     .EQ $11
 1060  *--------------------------------
 1070  BELL   .EQ $FBDD
 1080  RDLINE .EQ $FD6A
 1090  PRBYTE .EQ $FDDA
 1100  COUT   .EQ $FDED
 1110  CROUT  .EQ $FD8E
 1120  *--------------------------------
 1130  T
 1140         JSR RDLINE
 1150         TXA
 1160         BNE .1
 1170         RTS
 1180  .1     JSR CONVERT.DEC.TO.BIN
 1190         LDA XH
 1200         JSR PRBYTE
 1210         LDA XL
 1220         JSR PRBYTE
 1230         LDA #"="
 1240         JSR COUT
 1250         JSR CONVERT.BIN.TO.DEC
 1260         JSR CROUT
 1270         JMP T
 1280  *--------------------------------
 1290  CONVERT.DEC.TO.BIN
 1300         LDX #0
 1310         STX XL       least significant byte
 1320  *--    STX XI    ---ANY INTERMEDIATE BYTES---
 1330         STX XH       most significant byte
 1340  .1     LDA $200,X
 1350         EOR #"0"
 1360         CMP #10
 1370         BCS .3       ...END OF NUMBER
 1380         TAY          SAVE CURRENT DIGIT
 1390         LDA XL
 1400         STA SL
 1410  *--    LDA XI    ---ANY INTERMEDIATE BYTES---
 1420  *--    STA SI    ---FOLLOW THIS PATTERN------
 1430         LDA XH
 1440         JSR SHIFT.X
 1450         BCS .2       ...OVERFLOW
 1460         JSR SHIFT.X
 1470         BCS .2       ...OVERFLOW
 1480         STA SH
 1490         CLC
 1500         LDA XL
 1510         ADC SL
 1520         STA XL
 1530  *--    LDA XI    ---ANY INTERMEDIATE BYTES---
 1540  *--    ADC SI    ---FOLLOW THIS PATTERN------
 1550  *--    STA XI    ----------------------------
 1560         LDA XH
 1570         ADC SH
 1580         BCS .2       ...OVERFLOW
 1590         JSR SHIFT.X
 1600         BCS .2       ...OVERFLOW
 1610         STA XH
 1620         INX          SCAN TO NEXT DIGIT
 1630         TYA          GET DIGIT
 1640         ADC XL       LEAST SIGNIFICANT BYTE
 1650         STA XL
 1660         BCC .1       ...NO CARRY
 1670  *--    INC XI    ---ANY INTERMEDIATE BYTES---
 1680  *--    BNE .1    ---FOLLOW THIS PATTERN------
 1690         INC XH       MOST SIGNIFICANT BYTE
 1700         BNE .1       ...UNLESS OVERFLOW
 1710  .2     JSR BELL     SIGNAL OVERFLOW
 1720  .3     RTS
 1730  *--------------------------------
 1740  SHIFT.X
 1750         ASL XL       LEAST SIGNIFICANT BYTE
 1760  *--    ROL XI    ---ANY INTERMEDIATE BYTES---
 1770         ROL          ...MOST SIGNIFICANT BYTE IN A
 1780         RTS
 1790  *--------------------------------
 1800  CONVERT.BIN.TO.DEC
 1810         LDX #0       DIGIT COUNTER
 1820  *---DIVIDE BY TEN----------------
 1830  .1     LDA #0
 1840         LDY #16      2*(# Bytes being converted)
 1850  .2     CMP #5
 1860         BCC .3
 1870         SBC #5
 1880  .3     ROL XL
 1890  *--    ROL XI    ---ANY INTERMEDIATE BYTES---
 1900         ROL XH
 1910         ROL
 1920         DEY
 1930         BNE .2
 1940         PHA          SAVE DIGIT ON STACK
 1950         INX          COUNT THE DIGIT
 1960  *---NEXT DIGIT-------------------
 1970         LDA XL
 1980  *--    ORA XI    ---ANY INTERMEDIATE BYTES---
 1990         ORA XH
 2000         BNE .1
 2010  *---PRINT DECIMAL----------------
 2020  .4     PLA
 2030         ORA #"0"
 2040         JSR COUT
 2050         DEX
 2060         BNE .4
 2070         RTS
 2080  *--------------------------------

