After learning about some of the things the PACK script from Basic Utils from Alex Evans, I wondered how it compared to the Carl England CRUNCH program that ran directly on a CoCo.
The Test Program
First, I wanted to create a simple test program that would allow for lines to be packed together easily. To do this, I made a BASIC program that created a BASIC program. Each line would have a PRINT command followed by a quoted string of 32 characters (the width of the CoCo screen). My program creator looks like this:
0 'MTOOBIG.BAS
10 OPEN "O",#1,"TOOBIG.BAS"
20 FOR I=1 TO 26
30 PRINT #1,I*10;"PRINT ";CHR$(34);STRING$(32,64+I);CHR$(34);";"
40 NEXT
50 CLOSE #1
This program is designed to create a disk file, but it could have been modified to work on cassette by changing the device #1 to device #-1.
The resulting file “TOOBIG.BAS” can be loaded. It looks like this:
10 PRINT "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
20 PRINT "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
30 PRINT "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";
40 PRINT "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD";
50 PRINT "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE";
60 PRINT "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
70 PRINT "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG";
80 PRINT "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";
90 PRINT "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII";
100 PRINT "JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ";
110 PRINT "KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK";
120 PRINT "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL";
130 PRINT "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM";
140 PRINT "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN";
150 PRINT "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO";
160 PRINT "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP";
170 PRINT "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ";
180 PRINT "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR";
190 PRINT "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS";
200 PRINT "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT";
210 PRINT "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU";
220 PRINT "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";
230 PRINT "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW";
240 PRINT "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
250 PRINT "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";
260 PRINT "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
Carl England’s CRUNCH
The CRUNCH utility by Carl England can be found on his The Defeater disk. You can download it from the Color Computer Archive site:
https://colorcomputerarchive.com/search?q=Carl+England
With my working disk in Drive 0, I mounted Carl’s disk image in Drive 1 and copied the CRUNCH program to my disk so I could get to it easier.
With my “TOOBIG.BAS” program loaded, I can then LOADM”CRUNCH”:EXEC to run it. Here is an example of what CRUNCH looks like (but ignore the program size shown at the bottom of the screen; this screen shot it from an earlier article where I was using it on a different program):
For the correct size, here is the output of CRUNCH when processing on the “TOOBIG.BAS” test program:
You can see it managed to shrink the program by 102 bytes! There were no trailing quotes, REM statements, or THEN GOTOs to remove, but it could take out the space after each PRINT and pack the lines. Somewhat.
Inspecting the resulting program was not what I expected. It did some work, but not as much as it could — for example, while it did combine lines 10-60 in to one longer line, it left line 70 alone. The same thing happened with lines 140 and 210. This may be a bug.
UPDATE: Since I wrote this, I bribed William “Lost Wizard” Astle to disassemble the CRUNCH program for me, and provided the source to the original author Carl England (it was easier than hoping Carl could somehow find his source code from 23 years ago). Carl identified a one byte change to fix this issue, and I recompiled and it fixes the following behavior to match that of the Alex Evans tools. More on this in a future article…
10 PRINT"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";:PRINT"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";:PRINT"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";:PRINT"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD";:PRINT"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE";:PRINT"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
70 PRINT"GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG";
80 PRINT"HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";:PRINT"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII";:PRINT"JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ";:PRINT"KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK";:PRINT"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL";:PRINT"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM";
140 PRINT"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN";
150 PRINT"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO";:PRINT"PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP";:PRINT"QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ";:PRINT"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR";:PRINT"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS";:PRINT"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT";
210 PRINT"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU";
220 PRINT"VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";:PRINT"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW";:PRINT"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";:PRINT"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";:PRINT"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
Using my “BASLINES.BAS” test program, I can get some stats on the line lengths before and after:
ADDR NADDR LINE# SIZ 9729 9771 10 42 9771 9813 20 42 9813 9855 30 42 9855 9897 40 42 9897 9939 50 42 9939 9981 60 42 9981 10023 70 42 10023 10065 80 42 10065 10107 90 42 10107 10149 100 42 10149 10191 110 42 10191 10233 120 42 10233 10275 130 42 10275 10317 140 42 10317 10359 150 42 10359 10401 160 42 10401 10443 170 42 10443 10485 180 42 10485 10527 190 42 10527 10569 200 42 10569 10611 210 42 10611 10653 220 42 10653 10695 230 42 10695 10737 240 42 10737 10779 250 42 10779 10821 260 42 10821 10874 63000 53 10874 10997 63010 123 10997 0
The programs lines from 10 to 260 are all 42 bytes in length. The two lines after that are the BASLINES routine.
The CRUNCHed version looks like this:
ADDR NADDR LINE# SIZ 9729 9955 10 226 9955 9996 70 41 9996 10222 80 226 10222 10263 140 41 10263 10489 150 226 10489 10530 210 41 10530 10719 220 189 10719 10772 63000 53 10772 10895 63010 123 10895 0
It took 26 lines down to just seven, but the way it packed lines together is a bit odd, with a long line (226 bytes) then a short line (41 bytes), repeating. The 41 byte line is our original 42 byte line with the space after PRINT removed. The math checks out.
Alex Evans’ PACK
Alex Evans’ PACK did a better job, combining all 26 lines of code in to one impossibly long line:
0 PRINT"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";:PRINT"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";:PRINT"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";:PRINT"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD";:PRINT"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE";:PRINT"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";:PRINT"GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG";:PRINT"HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";:PRINT"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII";:PRINT"JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ";:PRINT"KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK";:PRINT"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL";:PRINT"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM";:PRINT"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN";:PRINT"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO";:PRINT"PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP";:PRINT"QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ";:PRINT"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR";:PRINT"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS";:PRINT"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT";:PRINT"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU";:PRINT"VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";:PRINT"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW";:PRINT"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";:PRINT"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";:PRINT"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
Using my “BASLINES” program, here is what it shows:
ADDR NADDR LINE# SIZ 9729 10695 0 966 10695 10748 63000 53 10748 10871 63010 123 10871 0
Yes, that’s right! Alex Evans’ PACK turned the entire 26 line program in to ONE line 0 that was 966 bytes long. Wowza.
I plan to do more tests to see if there are any tricks that CRUNCH does that PACK does not, so you have that to look forward to…
Until next time…