
 1000  * MULT16 DEMO
 1010  *SAVE MULT16 DEMO SOURCE
 1020  *--------------------------------
 1030  * DEMO OF BRUN'ING A ML PROG
 1040  * USING MULT16
 1050  *
 1060  * DOS IS DISCONNECTED
 1070  * TO ALLOW I/O WITHOUT
 1080  * DISRUPTING PROPER RETURN
 1090  *--------------------------------
 1100          .OP 65802
 1110          .OR $6A00
 1120  *--------------------------------
 1130  COUT1   .EQ $FDF0    SCREEN OUTPUT
 1140  KEYIN   .EQ $FD1B    KEYBOARD INPUT
 1150  *--------------------------------
 1160  AL      .EQ 0
 1170  AH      .EQ 1
 1180  BL      .EQ 2
 1190  BH      .EQ 3
 1200  DFLG    .EQ 4        DELIMITER FLAG
 1210  GETLN1  .EQ $FD6F    INPUT LINE TO BUFFER
 1220  PRNTAX  .EQ $F941    OUTPUT A,X AS HEX
 1230  CROUT   .EQ $FD8E    OUTPUT CR
 1240  *--------------------------------
 1250  DEMO
 1260          LDX #0       BEFORE ANY I/O,
 1270  .10     LDA $36,X     DISCONNECT DOS
 1280          PHA           BY PUSHING $36.39
 1290          LDA PTRS,X    ONTO STACK,
 1300          STA $36,X     & REPLACING
 1310          INX           WITH COUT1/KEYIN
 1320          CPX #4 
 1330          BNE .10
 1340   
 1350          JSR CROUT
 1360  .20     JSR GETLN1   INPUT LINE TO BUFFER
 1370          JSR HEXVALS  EXTRACT HEX VALUES
 1380          CPY #1       IF NULL LINE,
 1390          BEQ .80         THEN EXIT
 1400          JSR PROG     MULTIPLY
 1410          LDA BH
 1420          LDX BL
 1430          JSR PRNTAX   DISP HI-16
 1440          LDA AH
 1450          LDX AL
 1460          JSR PRNTAX   DISP LO-16
 1470          JSR CROUT
 1480          JMP .20
 1490    
 1500  .80     LDX #3       RECONNECT DOS
 1510  .90     PLA           BY PULLING 
 1520          STA $36,X     $36.39 FROM
 1530          DEX           THE STACK.
 1540          BPL .90
 1550          RTS
 1560  *--------------------------------
 1570  * REPLACEMENT I/O POINTERS
 1580  *--------------------------------
 1590  PTRS    .DA COUT1,KEYIN
 1600    
 1610  *--------------------------------
 1620  * READ TWO HEX 16-BIT WORDS
 1630  * FROM INPUT BUFFER. (AFTER WOZ)
 1640  *--------------------------------
 1650  BUFF    .EQ $200
 1660  *--------------------------------
 1670  HEXVALS
 1680          LDY #0       CLEAR BUFFER INDEX
 1690          STY DFLG     CLEAR DELIMITER FLAG
 1700  .10     LDA #0       CLEAR A
 1710          STA AL
 1720          STA AH
 1730  .20     LDA BUFF,Y   GET CHAR FROM BUFFER
 1740          INY
 1750          CMP #$8D     = CR ?
 1760          BNE .30
 1770          RTS
 1780    
 1790  .30     EOR #$B0     CONVERT ASCII TO HEX
 1800          CMP #$0A
 1810          BCC .40      IF 0-9
 1820          ADC #$88
 1830          CMP #$FA
 1840          BCS .40      IF A-F
 1850          LDA DFLG     ELSE ASSUME
 1860          BNE .10       CHAR IS
 1870          LDA AL        A DELIMITER.
 1880          STA BL       MOVE A TO B
 1890          LDA AH        IF NOT REPEATED
 1900          STA BH        DELIMITER
 1910          DEC DFLG     SET DELIMITER FLAG
 1920          JMP .10
 1930   
 1940  .40     ASL          SHIFT NIBBLE
 1950          ASL           TO LEFT HAND 
 1960          ASL           SIDE.
 1970          ASL
 1980          LDX #4       & ROL INTO MEMORY
 1990  .50     ASL
 2000          ROL AL
 2010          ROL AH
 2020          DEX
 2030          BNE .50
 2040          STX DFLG     CLEAR DELIMITER FLAG
 2050          JMP .20
 2060  *--------------------------------
 2070  * SUBROUTINE
 2080  *--------------------------------
 2090  PROG    .IN BUTTERILL'S MULTIPLY

