[comp.os.cpm] Zen and the art of CP/M

dg@pallio.UUCP (David Goodenough) (11/01/90)

The following article appeared in the PIPMAG online magazine on GEnie.
I found it interesting because of the history it contains, but also
because it explains why I spend my time beating my head against a 14"
green phosphor tube, covered with the Z80 assembler neumonics that
make up QTERM, when I could do it in C on the 386 UNIX crate at work,
and get it written much quicker.

It is reproduced with permission of the author.
-- 
	dg@pallio.UUCP - David Goodenough		+---+
						IHS	| +-+-+
	..... !harvard!xait!pallio!dg			+-+-+ |
AKA:	dg%pallio.uucp@xait.xerox.com			  +---+

-----------------------------------------------------------------------------
                       Zen and the Art of CP/M
   
                                  by

                     Robert Coleman (R.COLEMAN3)


It was late.  Maybe midnight, and quiet in the house.  Upstairs, my 
wife and son were probably asleep.  I could hear the faint sound of 
the TV droning; that and the soft breeze outside my opened window.  
Whoosh!  Drive A on my computer was busy at work.  I was backing up 
some files and doing general housekeeping after a long session at the 
keyboard.  Tic-tic, whoosh, tic-tic!  Drive B kicked in.  I watched.  
I had to smile.  It was noisier than drive A -- always was (I could 
close my eyes and tell which of my drives were running, just by the 
sounds they made).  Drive B was perhaps the better of the two.  It was 
newer.  But they were both slow; just as slow and tired as I was now.  
I looked up at the window and felt the cool breeze on my skin.  No, 
they weren't the fastest drives.  Not like the 1.2 Meg on my 386 at 
work.  That was much faster; faster by a country mile.  And I pushed 
it too -- pushed the hell out of it.  But that was work.  Now, just 
being here late at night with this old CP/M computer, it was somehow 
different...

Zen and the Art of CP/M?  (...like Motorcycle Maintenance?  [1]) 
Crazy?  Hey, I'm not the first to get this feeling of religious fervor 
over a computer operating system.  How about 'The SOUL of CP/M' and 
'The CP/M BIBLE' [2,3].  Mr. Waite and associates, they too had 
reverence for this IDEA.  In spite of MS-DOS, countless thousands 
still cling to CP/M.  Why?  Good question.  Perhaps it has more to do 
with the intangibles -- faith, acceptance, quiet devotion, and a brand 
of grass-roots, seat-of-the-pants wisdom.  The CP/Mer assumes a 
tongue-in-cheek posture; all the while, watching the rest of the 
computer world spin its wheels in a deluge of glitter, gloss and 
Madison Avenue hype.  It appears that regardless of the odds, in an 
era of disposable widgets and planned obsolescence, in the face of 
such staunch and resolute adversity, CP/M is here to stay.  In the 
words of one PIPMAG author, Jim Taylor, CP/M is 'the peoples operating 
system'.

It is interesting that in spite of CP/M's continued popularity, the 
name 'CP/M' has been interpreted to mean several things:  The CP/M 
Bible refers to it as 'control program for microprocessor'.  In one 
Digital Research, Inc. CP/M Users Manual dated 1979, it is referred to 
as 'control program for microcomputer'.  Still, I have heard it 
referred to as 'control program monitor'.  These discrepancies of 
course only add to the mystique.  I guess any CP/Mer worth his salt 
has read the basics, but just where DID CP/M come from?  Where does it 
fit into the computer world as we enter the 1990s?

Perhaps the largest MAINFRAME computer, and the grand-daddy of them 
all, was the UNIVAC computer of 1950.  Built entirely of vacuum tubes, 
it was so big it filled a large room.  And the PDP-8 MINICOMPUTER, 
costing a mere $50,000, brought computing to corporate business in the 
mid-60s.  But it was the advent of the microprocessor that made the 
MICROCOMPUTER a reality.  

In 1969, engineers at Datapoint Corporation of San Antonio, Texas, 
designed a simple central processing unit and contracted both Intel 
and Texas Instruments to implement the design on a single piece of 
silicon.  Intel succeeded, but the product ran ten times slower than 
had been agreed upon, so Datapoint backed out of the deal.  Intel 
decided to go ahead and market the device and called it the 8008 
microcomputer [4].  Little did they know that this humble device 
signaled the beginning of the microcomputer revolution.  

The 8008 was truly limited, and was used as a controller such as in 
robot stepper motors and push button TVs.  The 8080, more-or-less its 
direct descendent, was the first microprocessor with an instruction 
set powerful enough to do real data processing.  But these were still 
humble beginnings.  In 1974, a microcomputer kit was sold to hobbyists 
called the Altair 8800.  It featured switches to enter data, and LEDs 
as a monitor device.  There was no keyboard, no CRT, and no floppy 
drives, which meant no stored programs.  All programs had to be 
tediously entered by hand, byte by byte.  This was indeed the stone 
age of microcomputing.  They say that necessity is the mother of 
invention -- thus the birth of an operating system.  CP/M was 
originally developed by Gary Kildall in 1973 for testing 8" Shugart 
disk drives.  Later, in 1976, he founded Digital Research, Inc. and 
released CP/M, targeted at 8080 microcomputer hobbyists [5].  But the 
8080 was slow, and needed three different voltage levels and several 
support ICs to operate.  It was soon replaced by the 8085 which 
required only +5 volts to run.  Then, later came the Z80.  It was not 
only 8080/8085 software compatible, but included many additional, more 
powerful instructions.  By 1980, with the Z80, CP/M had truly become 
the industry standard.  

This is where Big Blue enters the picture.  Microcomputers by this 
time were starting to find use in the business world.  IBM realized 
the vast commercial potential and was gearing up for a major 
onslaught.  They had been associated with quality mainframe computers, 
and most experts agreed that they would become the leader in the 
microcomputer field -- in essence, they would decide the future of 
microcomputing.  IBM chose the 8088 microprocessor by Intel, and with 
Microsoft, they developed a new operating system called PC-DOS 
(essentially the same as MS-DOS -- Microsoft's stand alone version).  
Today, PC doesn't just mean personal computer -- it means IBM 
compatible.  

For the uninitiated, let's take a look inside these machines and 
see what all the fuss is about.  The 8088/8086 microprocessor, which 
is used in the PC-XT and its clones, is vaguely similar to our 8080 
(the NEC V20 version can run 8080 instructions).  It has an 8-bit data 
bus but 16-bit internal architecture and is considered a 16-bit 
microprocessor.  The 8086 is an upgrade with a full 16-bit data bus.  
The major feature of the 8088/8086 is the ability to address up to 1M 
of RAM using 'segment address-extension' registers.  This method is 
similar to CP/M 3.0's method of using multiple banks, only in the 
8088/8086, this technique is used to the fullest.  Much like the 8080, 
the 8086 can only use 64K at a time, but it has 10 banks of 64K each.  
This makes a total of 640K of RAM.  By using other tricks it can 
access many megabytes of additional memory.

Another member of the 8086 family is the 80286.  It provides 12 Mhz 
operation, a crude form of multi-tasking (running several SMALL 
programs at once) and is used in the PC-AT and its clones.  The 80386 
is another upgrade which provides up to 33 Mhz operation, a full 32-
bit bus and addressing up to 4 Gigabytes of memory.  And the 80486 is 
yet the latest upgrade, which provides further streamlining with a 
built-in cache memory controller and a coprocessor to speed up 
floating point calculations.  These microprocessors are currently 
considered the 'leading edge technology' and are the darlings of the 
micro world [6].  But even now, there is talk of MS-DOS being replaced 
in the 1990s with UNIX, a true multi-user/multi-tasking operating 
system.

There is another class of super microprocessors, such as the 
Motorola 88000.  These new devices use RISC technology (RISC -- 
'Reduced Instruction Set Computer').  They provide even faster 
execution by implementing a more efficient set of instructions and 
executing these within one machine cycle.  Whew!

Okay, so what does this mean for CP/M?  The microcomputer, which 
started out as an experiment and a boon for hobbyists has now become 
the workhorse of the corporate business establishment.  The 80286-386-
486 explosion is being fueled by big business, where money is no 
object and there is a constant demand for ever more speed and 
efficiency.  Through CAD (Computer Aided Design), these powerful 
microcomputers are now being used by scientists and engineers.  By 
connecting them together with LANs (Local Area Networks), some experts 
predict microcomputers will be direct competition for the minicomputer 
market which has already taken a beating in recent times.  But while 
these advances are impressive, it leaves one piece of the puzzle 
missing.  What about the consumer?  It is true, most people can afford 
a simple XT.  What does that mean really?  Today, most GOOD software 
written for MS-DOS is expensive.  And to enjoy the fruits of the 
leading edge, you have to constantly upgrade your equipment.  The 
latest software offerings for PCs aren't designed to run on two 
floppies -- a hard drive is MANDATORY.  A VGA monitor alone can cost 
more than an entire monochrome XT package.  Getting caught up in this 
spiraling staircase of madness is frightening and can lead to gross 
over-spending and perhaps even what I like to call 'PC-phobia' -- the 
fear of owning an inferior computer.  In reality, the PC revolution 
could be thought of as a plush banquet, where Big Business is picking 
up the tab, and the gamers are picking up the crumbs, hanging on to 
Sugar Daddy's coat tails.  

The dream among countless, now defunct computer manufacturers in 
the early 80s of fully automated lifestyles with a computer in every 
home was just that, a dream, and one that I fear will not soon be 
realized.  Let's face it, using a computer requires some effort, some 
learning on the part of the user.  You can't just turn it on like a 
VCR or a Nintendo.  Even the 'point and click' fad is too strenuous 
for most of the general public.  I venture to say that there is NO 
well defined home computer market.  All the non-IBM/clone platforms 
are beginning to fall away; ie:  Commodore C-series, Atari, even some 
Apple II-series.  The only true home computer market is really the 
COMPUTER HOBBYIST, and CP/M is still the ideal operating system for 
such a phenomenon.

It is conceivable that a CP/M supercomputer could be designed to 
have many of the bells and whistles of MS-DOS.  The HD64180 is an 
integrated Z80 microcontroller with several built-in features: 10 Mhz 
operation, two DMA controllers, two serial ports, and a programmable 
timer.  But the most notable feature is the ability to address up to 1 
Meg of memory using a built-in MMU (Memory Management Unit -- similar 
to the 'segment address-extension registers' in the 8086 family, 
previously mentioned).  A SCSI bus (Small Computer System Interface) 
could be used to interface up to eight devices; ie:  hard drives, 
floppy drives, tape drives, printers, etc.  This system could have 
high-resolution bit-mapped graphics, and perhaps even some form of 
multi-tasking (MP/M-II).  The only problem is that CP/M as we know it 
has no provisions for handling graphics, let alone 1 Meg of memory!  
Alas, I have found myself fantasizing at times about such a machine.  
I have personally designed several 68000 microprocessor-driven 
systems, and it would not be exceptionally difficult to implement the 
64180.  Of course, outside of a few crazies like myself, such a 
machine would have no commercial value in light of the current 
technologies.  It would merely be one CP/Mers dream of power and 
glory.  (NOTE: anyone out there who has similar ideas of building a 
CP/M supercomputer or who knows of such a beast, please drop me a line 
via GEnie mail. [Note - I posted asking about that large multi-user
CP/M system in the Netherlands a few days ago, I'd like to pass that
information on to Rob Coleman -- dg]

Anyway, what makes CP/M so special?  Well, to begin with, it was 
the first successful disk operating system.  Living life as a 
microcomputerist before CP/M was akin to living without indoor 
plumbing.  And to think that a boni fide computer system like the 
UNIVAC, that once filled an entire room, could now sit on a table top, 
I find astonishing.  And further, the BDOS/BIOS concept is ingenious.  
The compatablitily of CP/M operated systems allows the user to share 
the experience with dissimilar hardware platforms -- thus a whole 
computing community is enriched.  And even more, anyone who lives in 
the MS-DOS world can feel comfortable with CP/M.  After all, MS-DOS 
really grew out of CP/M; many of the commands and file handling 
schemes are similar.  But more than anything else, maybe SIMPLICITY is 
what makes CP/M so appealing.  As in Art, there is a beauty in 
simplicity and symmetry, combined with functionality.  And CP/M is 
just that, a simple, straight-forward solution to operating a personal 
microcomputer system.

I guess personal computing is different for others.  There's Dan-
the-man, my snippidy next door neighbor, the one with the super AT 
with VGA.  I have been to his house to marvel over his computer 
before, and it IS a remarkable machine.  It would be ridiculous to 
ignore the fact that this is no doubt a far superior machine to 
anything in the CP/M world.  The speed is overwhelming, the graphics 
dazzling.  It is awe inspiring, the shear, unbridled power!  (Excuse 
me, I get excited about computers -- any flavor.) Dan-the-man is 
indeed one happy camper, as well he should be.  But I am baffled.  
What I find unsettling is the way he PERCEIVES personal computing.

Case in point: No sooner did he get this amazing machine, then he 
was planning to buy another, more powerful one.  Why?  I'm not sure.  
Is it the 'first on the block' syndrome, or is it that he really needs 
that kind of computing power?  Dan-the-man plays many computer games 
and experiments with various software packages.  Now six months later, 
he's ready for a new machine.  He hasn't even learned how to use THIS 
one yet.  Speaking of falling in love with one's computer; Dan-the-man 
not only has no loyalty, he is a technological flirt!  In this 
relationship, there seems to be something missing.  Hmmm...

Anyone who would care to notice, would be astounded at the 
longevity of the Commodore 64 computer.  True, this little machine is 
edging its way to obsolescence, but what a journey it has seen!  
Nearly eight years after its debut, there is still a large group of 
devotees.  There are, as a rough guesstimate, about seven or eight 
million of these machines around the world.  Not all gamers either I 
remind you; there are multitudes of application programs that have 
been written for it.  With its handful of ROM-based kernel calls and 
its graphics capabilities, the C64 is a veritable programmer/hacker's 
delight.  How many imaginations have been stirred by these 8-bit 
wonders?  How many computer software careers do you suppose have been 
launched by these little 'toy' computers?  I have read articles in 
some trade magazines by professional programmers who STILL enjoy 
hacking on them.  These people really love the little computer.  In 
this relationship, there seems a great deal of dedication.  Obviously, 
personal computing means different things to different people.

Meanwhile, back in my den, whoosh-tic!  Both drives came to a halt.  
I read the directory of the backed-up floppy.  Everything looked good.  
I wondered, should I check for bad sectors?  But then again, the 
format command should have detected any of these.  I yawned.  Now I 
yearned for sleep.  Inadvertently, I ran scan.com to look for a bad 
sector, only I entered the A drive by mistake.  I cringed as I 
realized that my boot disk was now being scanned for bad sectors.  
This is NOT what I had intended.  So much for working when I was 
tired.  But behold!  There was a bad sector detected on my boot 
floppy!  I glared at the message on the monitor with disbelief.  I 
thought to myself, maybe the A drive was overheating.  That had to be 
it.  I ran scan.com again with the boot disk in the B drive.  Again -- 
a bad sector -- the same one.  I decided to fix the problem NOW.  No 
matter how tired I was, I couldn't go to sleep having my boot disk 
corrupted.  No way.  That would be sacrilege.  
    
I pulled out my back-up boot disk (yes, I had a back-up, but that 
is a different story!).  I pip'd the contents to my RAM drive and then 
reformatted the corrupted boot disk.  Outside my window, I heard a 
bird call, close in, near the house.  I looked briefly to the open 
window, then back to the task at hand.  Once again, I ran scan.com.  
Good!  No bad sectors.  Patiently, I waited as the RAM disk contents 
were copied back onto the boot floppy.  

'Booting' -- what an odd term.  In the early 1970s, practically all 
memories were magnetic core types.  These memories had tiny toroid-
shaped magnets spaced between a lattice-work of wires.  The direction 
of the current through one wire determined the logic value, and 
current through the other determined whether that value was read or 
written into the magnet-element.  These devices were non-volatile, and 
held their contents even when the power was removed.  But when this 
data was corrupted, a small program had to be entered to load the 
system code.  This was a tedious process in those days -- done either 
with switches or paper tape input.  The solution?  A small loader 
program was entered manually which loaded another program which 
actually loaded the system code.  This small loader program was called 
a 'bootstrap' loader.  The system was loaded, or pulled up by its own 
bootstraps.  Hence the term -- 'boot' [7].  

Whoosh-tic!  The A drive came to a stop.  I then rebooted.  It was 
done.  All was fine in the world.  Again, there was the bird outside 
my window.  I got up and walked over to have a look.  Again, I heard 
the cooing.  It came from the bushes near the tree out front.  It was 
really too dark to see.  Up in the sky, I could see the crescent moon 
hanging lazily in the heavens, amidst a slight veil of wispy cloud.  I 
listened and heard silence.  In the dim light, I glanced back at my 
computer; my reconditioned boot disk.  Yes...  all WAS fine in the 
world.  I was ready for sleep.

It has been said that perhaps the true delight is not in arriving 
at the destination, but in the journey itself; to occasionally stop 
and enjoy the view.  If even just to simply smell the fragrance of 
flowers, or ponder over a private thought.  I, myself, find the 
personal computing experience to be just that -- PERSONAL.  It is a 
quiet time alone, away from the stress and strain of everyday life.  
And it is during these times that I learn about strength and weakness, 
success and failure; the value of work; and play for the sake of play; 
and ways of acceptance.  Perhaps it is in this process of DOING that I 
find the real reward.  Knowing the joy of getting a five page, hand 
typed program to finally run.  Learning to accept that slow, noisy 
drive.  Learning that there is always another corner to turn, another 
page to read.  Learning that maybe there is wisdom in discovering even 
just one little, simple thing each day.  If only for this, it has been 
worth the while.  Oh yes, it could be model cars, or stamp collecting, 
or flower arranging.  But it is when these things cease to be mere 
objects and become vehicles, taking us someplace else, to some secret, 
private place, they bring us closer to the inner self.  By pouring 
over the tired guts of my old CP/M computer, cursing myself for having 
misplaced my screw driver AGAIN, perhaps I learn a little more about 
myself.  

                      References / Odds and Ends 

1.  Zen and the Art of Motorcycle Maintenance, Robert M. Pirsig, 
Bantam.  This book is not about fixing motorcycles, or even CP/M, but 
I strongly recommend it.  

2.  The Soul of CP/M, The Waite group, Howard Sams.  Out of print, but 
a real gem for programmers.  I have read excerpts from some old copies 
of Computers and Electronics magazine, but I don't own a copy myself.  
I'm still looking but to no avail.  (If anyone knows of an available 
copy please let me know.)

3.  The CP/M Bible, Waite and Angermeyer, Howard Sams.  Out of print.  
This book is useful for someone running several versions of CP/M.  It 
includes a handy cross reference section for 1.X, 2.X, and 3.X 
systems.  I found a NEW hard-bound copy in a used book shop for $4.  
Note:  Many CP/M computer books are now out of print but can be found 
at 'fire-sale' prices in used book stores.  With little money, you can 
build an impressive CP/M library.  

4.  An Introduction to Microcomputers, Vol. 1 Basic Concepts, Adam 
Osborne, Osborne/Mcgraw Hill.  A good book for newcomers or anyone who 
wants to know generally how a microcomputer works.

5.  TC128 Compendium #1, Issue #2, CP/M Update, by Todd Madson.  Any 
one who uses a C128 should subscribe to Twin Cities 128 magazine.  It 
deals ONLY with the Commodore 128.  But I must say, I wish there was 
more CP/M coverage.  

6.  EDN magazine, #24, Nov. 23, 1989.  The Annual uP/uC directory.  
This magazine is written for professional electronic design engineers 
and is a good source of info on new technology.

7.  CP/M Assembly Language Programming, Ken Barbier, Prentice Hall.  
As far as I know, this book is out of print.  However, it is an 
excellent tutorial on CP/M system programming with the 8080 
instruction set.

                     ----- About the Author -----

Robert Coleman is an electronics engineer for Data General, 
Telecommunication Products Division.  Besides designing 
microprocessor-based electronic circuits, and fiddling around with 
CP/M in his spare time, he enjoys reading, writing and playing bass in 
a part-time rock 'n' roll band.