10 ;BASIC PROFILER COUNT ANALYZER›20 ; XE VERSION BY ERIC WOODRUFF›30 ; (c) 1989, ANTIC PUBLISHING›40 ;›50 ; DEFINITIONS:›60 ;The buffer is a string address passed to the routine (BTNK).›70 ; 4 bytes per entry:›80 ; Lo, Hi of line number (counter).›90 ; Lo, Hi of count.›0100 ;›0110 MEMPTR = $CB ;Memory pointer.›0120 SRCH = $CD ;Search pointer.›0130 AMOUNT = $CF ;Number to bottlenecks to get.›0140 PBSAV = $D0 ;PORTB save location.›0150 LAST = $D4 ;Last highest bottleneck.›0160 COUNT = $DA ;Line # counter.›0170 ADSAV = $DC ;Search address save location.›0180 BTNK = $DE ;Bottleneck string address pointer.›0190 MAYB = $E0 ;Holder for a possibility.›0200 PORTB = $D301 ;For bank selection.›0210 ;›0220 *= $9A00›0230 ;›0240 ; This sorts through all the›0250 ; counters in extended RAM and›0260 ; send the specified number of›0270 ; entries to the buffer for a›0280 ; report to the user.›0290 ;›0300 PLA ›0310 PLA ;Get the passed›0320 STA BTNK+1 ;string address.›0330 STA ADSAV+1 ;For search.›0340 PLA ›0350 STA BTNK›0360 STA ADSAV›0370 PLA ;Get number of›0380 PLA ;bottlenecks to›0390 STA AMOUNT ;find.›0400 LDA PORTB ;Save PORTB.›0410 STA PBSAV›0420 ANALYZE›0430 LDA #0 ;Start from 0›0440 STA COUNT ;and go through›0450 STA COUNT+1 ;32767.›0460 STA LAST+2 ;Clear last›0470 STA LAST+3 ;bottleneck.›0480 CHECK›0490 LDA COUNT ;Move counter›0500 STA MEMPTR ;to pointer.›0510 LDA COUNT+1›0520 ASL A ;Multiply by›0530 CLC ;two to get›0540 ASL MEMPTR ;address in›0550 ADC #0 ;extended RAM.›0560 CMP #$40›0570 BCS SB1 ;Select bank 0?›0580 LDY #0›0590 BEQ SELC›0600 SB1 CMP #$80 ;Select bank 1?›0610 BCS SB2›0620 LDY #1›0630 BNE SELC›0640 SB2 CMP #$C0 ;Select bank 2?›0650 BCS SB3›0660 LDY #2›0670 BNE SELC›0680 SB3 LDY #3 ;Select bank 3.›0690 SELC AND #$3F›0700 ORA #$40 ;Find counter›0710 STA MEMPTR+1 ;in RAM.›0720 TYA ›0730 ASL A ;Bank * 4 + 193.›0740 ASL A›0750 CLC ›0760 ADC #193›0770 STA PORTB›0780 LDY #1›0790 LDA (MEMPTR),Y ;Check count.›0800 BNE NOTZ›0810 DEY ;Equal zero?›0820 LDA (MEMPTR),Y›0830 BEQ NEXT ;If so, ignore.›0840 INY ›0850 NOTZ›0860 LDA (MEMPTR),Y ;Is this›0870 STA MAYB+3 ;counter greater›0880 CMP LAST+3 ;than the last?›0890 BCC NEXT›0900 BNE SEEK ;Yes.›0910 DEY ›0920 LDA (MEMPTR),Y ;Check lo›0930 CMP LAST+2 ;byte.›0940 BCC NEXT ;No.›0950 SEEK LDY #0 ;Load lo byte›0960 LDA (MEMPTR),Y ;if not done.›0970 STA MAYB+2›0980 LDA COUNT+1›0990 STA MAYB+1 ;Store counter.›1000 LDA COUNT›1010 STA MAYB ;Save it.›1020 LDA PBSAV ;Switch back to›1030 STA PORTB ;normal memory.›1040 LDA ADSAV ;Restore search›1050 STA SRCH ;address.›1060 LDA ADSAV+1›1070 STA SRCH+1 ;See if counter›1080 LOOK LDY #0 ;is already in›1090 LDA (SRCH),Y ;the string.›1100 CMP MAYB ;Lo bytes =?›1110 BNE FAIL›1120 INY ›1130 LDA (SRCH),Y›1140 CMP MAYB+1 ;Hi bytes =?›1150 BEQ NEXT›1160 FAIL›1170 LDA #4 ;Check next›1180 CLC ;entry.›1190 ADC SRCH›1200 STA SRCH›1210 BCC *+4›1220 INC SRCH+1›1230 LDY #0 ;End of string?›1240 LDA #$FF›1250 CMP (SRCH),Y›1260 BNE LOOK›1270 INY ›1280 CMP (SRCH),Y›1290 BNE LOOK›1300 LDX #3 ;Move MAYB to›1310 MML LDA MAYB,X ;LAST.›1320 STA LAST,X›1330 DEX ›1340 BPL MML›1350 NEXT LDA PBSAV ;Switch back to›1360 STA PORTB ;normal memory.›1370 INC COUNT ;Increment to›1380 BNE NXT ;the next›1390 INC COUNT+1 ;counter.›1400 BMI *+5 ;Count=32768?›1410 NXT JMP CHECK›1420 LDY #3 ;Store the›1430 STR LDA LAST,Y ;counter and›1440 STA (BTNK),Y ;number to the›1450 DEY ;string.›1460 BPL STR›1470 LDA BTNK ;Add four to›1480 CLC ;bottleneck›1490 ADC #4 ;string address.›1500 STA BTNK›1510 BCC *+4›1520 INC BTNK+1›1530 DEC AMOUNT›1540 BEQ *+5 ;Done?›1550 JMP ANALYZE ;Find next one.›1560 RTS ;All done, exit.›