CP/M ON THE C128 (ARTICLE 1) by Noel Nyman (Copyright 1986 by Geoduck Developmental Systems. Permission to reprint this material is hereby granted, provided this notice is included in the reprinted material.) In this column we plan to explore CP/M (Control Program for Microcomputers) and how to use it on the C128. A special INPUT CP/M1 disk is also available with the latest CP/M operating system, several programs, and reprints of these columns (see the disk order form elsewhere in this issue). To understand the what and why of CP/M, we have to go back to the early days of microcomputing. In this primitive time there were mainframes, huge and expensive computers. Communicating with one required a "console" which had a keyboard and an output device. The output was frequently a printer, although the cathode ray tube (CRT or tv screen) was becoming more common. Refurbished teletype machines were often used as consoles. In the early 1970's a revolution began that would change the course of computing...the LSI (Large Scale Integration) micro chip. It became possible to produce on a single piece of silicon all the logic in CPU's (Central Processing Units) requiring several circuit boards on the mainframes. The first popular microprocessor chip, the 8080 designed by Intel, was used to make intelligent terminals. These were consoles that contained a keyboard and CRT monitor, a small amount of RAM (Random Access Memory) and some means of communicating with a mainframe. The large hard disks and tape drives used by the main frames were too complex for a microcomputer to control (there wasn't enough RAM to hold the controller program required). So the micros used paper tape. A punch poked rows of up to seven holes in the half-inch wide tape, each hole representing a bit in a seven bit character or command. A paper tape reader translated these holes into binary data to store in the micro. Storing a program was noisy and slow. In 1973 IBM developed the first floppy disks as alternatives to the then popular punch cards used on mainframes. Gary Kildall at Intel obtained a used drive from a small company named Shugart and began working on a controller program to interface it with an 8080 based microcomputer. He and John Torode developed the controller into a full disk drive operating system, which they called CP/M. Intel wasn't much interested in the project, and Kildall and Torode began marketing the product on their own through Digital Research in 1976. The rest, as they say, is history. CP/M is an operating system. Every computer needs an operating system in order to interface with the console, the disk drives, and any other peripherals such as modems and printers. In the relatively advanced age we live in, home computers usually come with their operating systems in ROM (Read Only Memory). When you power up your C128, it "knows" how to talk to the keyboard, screen, etc. The Commodore disk drives have their operating systems in ROM also. You don't need to LOAD any program in order to type on the keyboard, print characters on the screen, or find a file on a floppy disk. In 1973 computers were much less smart. Partly this was due to the high costs of both RAM and ROM. A 32K machine cost in excess of $3000 without peripherals (1973 dollars, gasoline was still under $0.20 a litre then). ROM was very expensive and difficult to program, EPROM's (Erasable Programmable Read Only Memory) weren't available. Each time you turned the power on, you had to teach the computer how to be a computer all over again. You did that by writing a program called the operating system, and SAVEing on disk or paper tape. You used another smaller program that often was typed in by hand each time to LOAD the larger program. This method of using a program to LOAD other programs was called "bootstrapping" since the computer was in a sense lifting itself by its own bootstraps. The idea of "BOOTing" an operating system remains with us, and is a command recognized by Basic 7.0. CP/M provided a standardized operating environment on many different computers. For example, the TRS-80 machines use the command LPRINT to send strings to a printer. Commodore uses PRINT# followed by a file number. But any printer routine written on a machine running under CP/M will run on any other CP/M machine (I'm not sure why "running under" is used, but that's the proper term). CP/M comes in four main sections. The first is the LOADing routine, which is usually on reserved tracks on CP/M disks. On the C128, the LOADer is found in ROM. The two workhorses of CP/M are the BDOS (Basic Disk Operating System) and the BIOS (Basic Input-Output System). Note that the term "Basic" as used here is a synonym for "primary" or "essential" and does not refer to the BASIC programming language. The BDOS is identical for all CP/M systems of the same version. BDOS works much like the Kernal jump table in Commodore machines, providing access to the routines for opening disk files, printing strings, and such by simply calling them by number. The BIOS is customized for each computer model. When the BDOS is asked to open a file, it uses several BIOS routines which are customized for the disk drives, data buss structure, etc. The last section is a program call CCP (Console Command Processor). The CCP accepts input from the keyboard, displays it on the screen, and places it in memory where appropriate for execution by other programs. On most systems the CCP must be reLOADed after other programs finish execution. On the C128, the CCP is always resident. There have been several versions of CP/M produced since 1973. The C128 runs under CP/M 3.0 (sometimes called CP/M+). This is the most advanced CP/M available, used computers with bank switching capability and over 64K of RAM can use it. If you'd like to read more about CP/M, there are many books available. Since it's a relatively old system, your library may be a good source of information. Try to get material for CP/M+, since some commands for older CP/M versions are different. Some good references are: THE CP/M PLUS HANDBOOK, Alan R. Miller, Sybex CP/M AND THE PERSONAL COMPUTER, Dwyer & Critchfield, Addison-Wesley If the date on the screen when you BOOT CP/M is older than December 4, 1985, you should get a copy of the new operating system. This is available from CompuServe, Q-Link, the INPUT CP/M1 disk, or perhaps a user in your area has one. ----Some additional references---- DR DOBB'S JOURNAL, especially earlier issues, covers CP/M extensively, you local library may have past issues available. For an interesting article by Gary Kildall on the start of CP/M, see the January 1980 issue. Old copies of BYTE, KILOBAUD MICROCOMPUTING, and INTERFACE AGE also have articles on CP/M. For a series on CP/M+, check the February 1983 issue of MICROSYSTEMS. Two CP/M user groups have disks available with a variety of programs. The 1571 drive will read KayPro IV format. For more information, contact: CPMUG/Lifelines 1651 Third Ave New York NY 10028 USA SIG/M PO Box 97 Iselin NJ 08830 USA The Dwyer & Critchfield book above has excellent reference sections on programming under CP/M in Z80 and 8080 machine code. For more details on Z80, try: Z80 ASSEMBLY LANGUAGE PROGRAMMING Lance Leventhal Osborne/McGraw-Hill Z80 ASSEMBLY LANGUAGE ROUTINES Leventhal and Saville Osborne/McGraw-Hill