0100 ; BASIC PROFILER SOURCE CODE 0110 ; BY STAN LACKEY 0120 ; (c)1988, ANTIC PUBLISHING INC. 0150 ; 0160 ; Definitions: 0180 TEMP1 = $CB ; Temps used in routines 0190 TEMP2 = $CD 0200 TEMP3 = $CF 0210 STMCUR = 138 ; Pointer into user program 0220 RAMTOP = 106 0250 ; 0260 *= $9F00 0270 ; 0280 PROFEN 0285 .BYTE 0 ; Flag to enable Profiler 0290 ; 0300 ; SAMPLE is the timer interrupt 0310 ; routine. It takes the current 0320 ; line number, divides it by 10 0330 ; and increments that 16-bit 0340 ; location in the RAM above 0345 ; RAMTOP. 0350 ; 0360 SAMPLE 0365 LDA PROFEN ; Sense enable 0370 BNE SPL1 0375 ; 0380 PLA ; It's off... 0390 RTI ; just return. 0395 ; 0400 SPL1 0401 TYA 0410 PHA ; Must save Y 0420 LDY #0 0430 LDA (STMCUR),Y ; Get line # 0440 STA TEMP1 0450 INY ; Point to high 0460 LDA (STMCUR),Y 0470 STA TEMP1+1 0480 BMI EXIT ; Exit if line 0490 ; num is neg. 0500 ; Now, divide line number by 10 0510 LDA # <20480 ; Divisor: 0520 STA TEMP2 ; #10, Shifted 0530 LDA # >20480 0540 STA TEMP2+1 0550 LDA #0 0560 STA TEMP3 ; Clear quotient 0570 STA TEMP3+1 0580 LDY #11 ; Loop count 0590 DIVLP 0595 SEC 0600 LDA TEMP1 0610 SBC TEMP2 0620 STA TEMP4 ; 16-bit subtr, 0630 LDA TEMP1+1 ; ddnd-dvsr 0640 SBC TEMP2+1 0650 STA TEMP4+1 0660 CLC ; Init. 0670 BMI NOBIT ; Shift 0 in 0680 ; dvsr > ddnd 0690 LDA TEMP4 0700 STA TEMP1 ; ddnd > dvsr 0710 LDA TEMP4+1 ; Copy new ddnd 0720 STA TEMP1+1 0730 SEC ; Shift 1 in 0740 NOBIT 0745 ROL TEMP3 ; Shift into 0750 ROL TEMP3+1 ; quotient 0760 LSR TEMP2+1 ; Shift dvsr 0770 ROR TEMP2 0780 DEY 0790 BPL DIVLP ; Loop next bit 0795 ; 0800 ; Result is left in TEMP3. 0810 ; Add that result to RAMTOP. 0820 ASL TEMP3 ; 2x result for 0830 ROL TEMP3+1 ; 2-byte access 0840 CLC 0850 LDA TEMP3+1 0860 ADC RAMTOP ; TEMP3 is now 0870 ADC #4 ; the pointer 0880 STA TEMP3+1 ; into the RAM. 0890 LDY #0 0900 CLC 0910 LDA (TEMP3),Y ; Get cell to 0920 ADC #1 ; increment 0930 STA (TEMP3),Y 0940 BNE EXIT ; If inc. to 0, 0945 ; 0950 INY 0960 CLC 0970 LDA (TEMP3),Y ; incr high 0980 ADC #1 ; half 0990 STA (TEMP3),Y 1000 BPL EXIT ; Test overflow 1005 ; 1010 LDA #0 ; Stop prof 1020 STA PROFEN ; on overflow 1030 EXIT 1035 PLA 1040 TAY ; Restore Y 1050 PLA ; and A 1060 RTI ; End of SAMPLE 1065 ; 1070 TEMP4 1075 .WORD 0 ; Temp used in division
Back to previous page