!pr2
Counting Lines......................................Bill Morgan

When Bob and I were first looking at Bruce Love's version of the Spiral Screen Clear, we got to wondering just how many lines actually were being processed by the assembler.  With all those nested recursive macros, the total was bound to be in the thousands.  Here's a little filter program I threw together to do a count:


0000-          1000 COUNT.LO .EQ 0
0001-          1010 COUNT.HI .EQ 1
0036-          1020 OUTHOOK  .EQ $36
03EA-          1030 DOSHOOK  .EQ $3EA
               1040 *--------------------------------
               1050        .OR $300
               1060  
0300- A9 00    1070        LDA #0
0302- 85 00    1080        STA COUNT.LO      zero the counters
0304- 85 01    1090        STA COUNT.HI
0306- A9 11    1100        LDA #LINE.COUNTER
0308- 85 36    1110        STA OUTHOOK       direct output
030A- A9 03    1120        LDA /LINE.COUNTER to my routine
030C- 85 37    1130        STA OUTHOOK+1
030E- 4C EA 03 1140        JMP DOSHOOK
               1150 *--------------------------------
               1160 LINE.COUNTER
0311- C9 8D    1170        CMP #$8D          carriage return?
0313- D0 06    1180        BNE .1            no, exit
0315- E6 00    1190        INC COUNT.LO      yes, count it
0317- D0 02    1200        BNE .1
0319- E6 01    1210        INC COUNT.HI
031B- 60       1220 .1     RTS


I assembled that code at $300, and then used these commands to set the PRT vector:

!lm+5
:$C083 C083 D009:4C 0 3 N C080
!lm-5

(For the motherboard versions of the S-C Assemblers, you only need to type :$1009:4C 0 3)

With that in place just load a source file, set .LIST ON, type PRT, and then type ASM.  When the assembly is finished, type PR#0 to get the output back to the screen.  Now you can type :$0.1 to look at the counters.  You might also want to put a .LIST OFF line at the end of your program, so the count won't include the Symbol Table.

By the way, when the macros are expanded those 80 lines of Bruce's program produce 13,593 lines of code, or enough to fill over 200 pages of printout.
