How Many Bytes to the Line?

Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v2 n1 (Volume 2, Issue 1)
Date: January 1981
Pages: 6-7

This subroutine determines the exact number of bytes used for each line of program instruction as well as an entire program.

Enter a decimal starting address after the first prompt (the lowest line number always starts at 16426). The program shows the starting address and contents of each line. Subtract one starting address from the next to see how many bytes that line uses. Press (NL) to see each screenful of information. At the end, it will display the number of instructions, total bytes, average bytes and the starting address available for the next program. This routine assumes it will find a code 248 (STOP), so make sure each program ends with a STOP.

To exit, enter E (NL) when it asks for next program. To analyze another program, type it in ahead of this one with smaller line numbers. Type RUN 9200 (NL). To go on to another program, hit (NL) after NEXT PROGRAM, then enter the starting address given for the next program.

9200 REM DUMP INSTRUCTIONS
9205 PRINT "START AT?"
9210 INPUT S
9215 LET B=S
9220 LET C=0
9225 CLS
9230 FOR I=1 TO 15
9235 PRINT S,
9240 LET C=C+1
9245 IF PEEK(S)=118 THEN GO TO 9270
9250 PRINT CHR$(PEEK(S));
9255 IF PEEK(S)=248 THEN GO TO 9310
9260 LET S=S+1
9265 GO TO 9245
9270 PRINT
9275 LET S=S+3
9280 NEXT I
9290 INPUT Z$
9295 IF Z$="E" THEN GO TO 9390
9300 GO TO 9225
9310 PRINT
9315 PRINT
9320 PRINT C,"INSTRUCTIONS"
9325 LET A=S-B+1
9330 PRINT A,"BYTES"
9335 LET D=A/C
9340 PRINT D,"AVERAGE BYTES"
9345 LET S=S+4
9350 PRINT S,"NEXT PROGRAM"
9355 INPUT Z$
9360 IF Z$="E" THEN GO TO 9390
9370 IF Z$="" THEN GO TO 9215
9375 GO TO 9205
9390 PRINT "END DUMP"
9392 GO TO 9399
9395 RETURN
9399 STOP

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.