
 1000  *SAVE S.MULTIPLY 16X16
 1010  *--------------------------------
 1020  PLICAND    .EQ $00,01    MULTIPLICAND
 1030  PLIER      .EQ $02,03    MULTIPLIER, LO-16 OF PRODUCT
 1040  PRODUCT    .EQ $04,05    HI-16 OF PRODUCT
 1050  *--------------------------------
 1060         .OP 6502
 1070  *--------------------------------
 1080  MULTIPLY.16X16.6502
 1090         LDX #16
 1100  .1     LDA PLIER    CHECK NEXT BIT OF MULTIPLIER
 1110         LSR
 1120         BCC .2       ...DON'T ADD MULTIPLICAND
 1130         CLC
 1140         LDA PRODUCT
 1150         ADC PLICAND
 1160         STA PRODUCT
 1170         LDA PRODUCT+1
 1180         ADC PLICAND+1
 1190         STA PRODUCT+1
 1200  .2     ROR PRODUCT+1
 1210         ROR PRODUCT
 1220         ROR PLIER+1
 1230         ROR PLIER
 1240         DEX
 1250         BNE .1
 1260         RTS
 1270  *--------------------------------
 1280         .OP 65802
 1290  *--------------------------------
 1300  MULTIPLY.16X16.65802.SMALLER
 1310         CLC
 1320         XCE          NATIVE MODE
 1330         REP #$20     A-REG 16-BITS
 1340         LDX #16      LOOP 16 TIMES
 1350  .1     LDA PLIER    CHECK NEXT BIT OF MULTIPLIER
 1360         LSR
 1370         LDA PRODUCT  GET HI-16 OF PRODUCT
 1380         BCC .2       ...DO NOT NEED TO ADD
 1390         CLC
 1400         ADC PLICAND
 1410  .2     ROR
 1420         STA PRODUCT
 1430         ROR PLIER    USE FOR LO-16 OF PRODUCT
 1440         DEX
 1450         BNE .1
 1460         SEC
 1470         XCE          BACK TO EMULATION MODE
 1480         RTS
 1490  *--------------------------------
 1500  MULTIPLY.16X16.65802.FASTER
 1510         CLC
 1520         XCE          NATIVE MODE
 1530         REP #$20     A-REG 16-BITS
 1540         LDA PLICAND
 1550         BEQ .3       0*ANYTHING=0
 1560         DEC
 1570         STA PLICAND
 1580         LDX #16      LOOP 16 TIMES
 1590  .1     LDA PLIER    CHECK NEXT BIT OF MULTIPLIER
 1600         LSR
 1610         LDA PRODUCT  GET HI-16 OF PRODUCT
 1620         BCC .2       ...DO NOT NEED TO ADD
 1630         ADC PLICAND
 1640  .2     ROR
 1650         STA PRODUCT
 1660         ROR PLIER    USE FOR LO-16 OF PRODUCT
 1670         DEX
 1680         BNE .1
 1690         SEC
 1700         XCE          BACK TO EMULATION MODE
 1710         RTS
 1720  .3     LDA PRODUCT  INITIAL ADDEND
 1730         STA PLIER    LOW 16 OF PRODUCT
 1740         STZ PRODUCT  HIGH 16 OF PRODUCT
 1750         SEC
 1760         XCE          BACK TO EMULATION MODE
 1770         RTS
 1780  *--------------------------------
 1790         .LIF

