Classic Computer Magazine Archive PROGRAM LISTING: 89-10a/PROFILE.M65


10 ;BASIC PROFILER SOURCE CODE
20 ; BY STAN LACKEY
30 ;
40 ; 130XE VERSION BY ERIC WOODRUFF
50 ; (c) 1989, ANTIC PUBLISHING, INC.
60 ;
70 ;
80 ; DEFINITIONS:
90 STMCUR =  $8A     ;Pointer into user program.
0100 MEMPTR = $D0    ;Memory pointer.
0110 PROFEN = $04FE  ;Profiler On/Off flag.
0120 PORTB = $D301
0130 ;
0140     *=  $0600   ;Relocatable.
0150 ;
0160 ;  SAMPLE is the timer interrupt
0170 ; routine. It takes the current
0180 ; line number, multiplies it by
0190 ; 2, and swaps in the correct
0200 ; bank of extended RAM to bump
0210 ; up the 16-bit line counter.
0220 ; With the extra 64K, each line
0230 ; (0-32767) has its own counter.
0240 ;
0250 SAMPLE
0260     LDA PROFEN  ;Is profiler
0270     BEQ OUT     ;active?
0280 ;If not, exit.
0290 ;
0300 SPL1
0310     TYA         ;Must save Y.
0320     PHA 
0330     LDA PORTB   ;Save PORTB.
0340     PHA 
0350     LDY #0      ;Get the
0360     LDA (STMCUR),Y ;line number.
0370     STA MEMPTR
0380     INY 
0390     LDA (STMCUR),Y ;High byte.
0400     BMI ERR     ;Line # > 32767.
0410 ;Line ok, so increment counter.
0420 ;
0430     ASL A       ;Multiply by
0440     CLC         ;two to get
0450     ASL MEMPTR  ;address in
0460     ADC #0      ;extended RAM.
0470     CMP #$40    ;Select bank 0?
0480     BCS SB1
0490     LDY #0
0500     BEQ SELC
0510 SB1 CMP #$80    ;Select bank 1?
0520     BCS SB2
0530     LDY #1
0540     BNE SELC
0550 SB2 CMP #$C0    ;Select bank 2?
0560     BCS SB3
0570     LDY #2
0580     BNE SELC
0590 SB3 LDY #3      ;Select bank 3.
0600 SELC AND #$3F
0610     ORA #$40    ;Find counter
0620     STA MEMPTR+1 ;in RAM.
0630     TYA 
0640     ASL A       ;Bank * 4 + 193.
0650     ASL A
0660     CLC 
0670     ADC #193
0680     STA PORTB   ;Switch to it.
0690     LDY #0      ;Increment the
0700     LDA (MEMPTR),Y ;line's
0710     CLC         ;counter.
0720     ADC #1
0730     STA (MEMPTR),Y
0740     BCC EXIT
0750     INY         ;Carry, so
0760     LDA (MEMPTR),Y ;increment
0770     ADC #0      ;high half.
0780     STA (MEMPTR),Y
0790     BNE EXIT    ;Overflow test.
0800 ERR
0810     LDA #0      ;Stop: Overflow
0820     STA PROFEN  ;or line>32767.
0830 EXIT
0840     PLA 
0850     STA PORTB   ;Restore PORTB.
0860     PLA 
0870     TAY         ;Restore Y reg.
0880 OUT PLA 
0890     RTI         ;End of SAMPLE.


Back to previous page