Classic Computer Magazine Archive PROGRAM LISTING: 84-02/STOCK2.ASM


1000         *=$600
1010 ;
1020 SAVMSC  =       $58
1030 FR0     =       $D4
1040 FRE     =       $DA
1050 FR2     =       $E0
1060 FR1     =       $E6
1070 CIX     =       $F2
1080 INBUFF  =       $F3
1090 ;
1100 ; X=USR(1536,ADR(A$),N,L)
1110 ;
1120 ; A$ - ENTRIES TO BE SORTED
1130 ; N  - NUMBER OF ENTRIES
1140 ; L  - LENGTH OF ENTRIES
1150 ; X  - ADDRESS OF POINTER TABLE
1160 ;
1170         PLA
1180         PLA
1190         STA     INBUFF+1
1200         PLA
1210         STA     INBUFF
1220         PLA
1230         PLA
1240         STA     CIX
1250         PLA
1260         PLA
1270         STA     FR0+4
1280         STA     FR0+3
1290         DEC     FR0+3
1300         LDX     SAVMSC+1
1310         DEX
1320         STX     FR0+1
1330         DEX
1340         STX     FR1+1
1350         DEX
1360         STX     FR2+1
1370         LDY     #0
1380         STY     FR0
1390         STY     FR1
1400         STY     FR2
1410         STY     FR0+2
1420 PASS0   TYA
1430         STA     (FR0),Y
1440         INY
1450         BNE     PASS0
1460 ;
1470 PASS1   CLC
1480 PASS2   ROR     FR0+2
1490         LDY     #0
1500         TYA
1510 SET1    PHA
1520         BIT     FR0+2
1530         BPL     NADD
1540 ;
1550         CLC
1560         ADC     (FR2),Y
1570 NADD    TAX
1580         PLA
1590         STA     (FR2),Y
1600         TXA
1610         INY
1620         BNE     SET1
1630 ;
1640         LDX     #0
1650 ORDR    TXA
1660         TAY
1670         LDA     (FR0),Y
1680         PHA
1690         STA     FR0+5
1700         LDA     #0
1710         STA     FRE+1
1720         LDY     #$07
1730 SHFT    ASL     A
1740         ROL     FRE+1
1750         ASL     FR0+5
1760         BCC     NEXB
1770 ;
1780         CLC
1790         ADC     FR0+4
1800         BCC     NEXB
1810 ;
1820         INC     FRE+1
1830 NEXB    DEY
1840         BPL     SHFT
1850 ;
1860         CLC
1870         ADC     INBUFF
1880         STA     FRE
1890         LDA     FRE+1
1900         ADC     INBUFF+1
1910         STA     FRE+1
1920         LDY     FR0+3
1930         LDA     (FRE),Y
1940         TAY
1950         LDA     (FR2),Y
1960         PHA
1970         CLC
1980         ADC     #1
1990         STA     (FR2),Y
2000         PLA
2010         TAY
2020         PLA
2030         STA     (FR1),Y
2040         INX
2050         CPX     CIX
2060         BCC     ORDR
2070 ;
2080         BIT     FR0+2
2090         BPL     PASS2
2100 ;
2110         LDA     FR0+1
2120         LDX     FR1+1
2130         STX     FR0+1
2140         STA     FR1+1
2150         DEC     FR0+3
2160         BPL     PASS1
2170         RTS
2180 ;
2190         .END

Back to previous page