Online Book Reader

Home Category

Code_ The Hidden Language of Computer Hardware and Software - Charles Petzold [136]

By Root 1653 0
disk into memory. The ROM in a computer that uses CP/M need not be extensive. All the ROM needs to contain is a small piece of code known as a bootstrap loader (because that code effectively pulls the rest of the operating system up by its bootstraps). The bootstrap loader loads the very first 128-byte sector from the diskette into memory and runs it. This sector contains code to load the rest of CP/M into memory. The entire process is called booting the operating system.

Eventually, CP/M arranges itself to occupy the area of RAM with the highest memory addresses. The entire organization of memory after CP/M has loaded looks like this:

This diagram isn't to scale. The three components of CP/M—the Basic Input/ Output System (BIOS), the Basic Disk Operating System (BDOS), and the Console Command Processor (CCP)—occupy only about 6 KB of memory in total. The Transient Program Area (TPA)—about 58 KB of memory in a 64-KB computer—initially contains nothing.

The Console Command Processor is equivalent to the command processor that we were building earlier. The word console refers to a combination of a keyboard and a display. The CCP displays a prompt on the display, which looks like this:

A>

The prompt is your signal to type something in. In computers that have more than one disk drive, the A refers to the first disk drive, the one from which CP/M was loaded. You type in commands following the prompt and press the Enter key. The CCP then executes these commands, which usually produces information displayed on the screen. When the command has finished, the CCP displays the prompt again.

The CPP recognizes just a few commands. Possibly the most important is this one:

DIR

which displays the directory of the disk—that is, a list of all the files stored on the disk. You can use the special characters ? and * to limit this list to files of a particular name or type. For example,

DIR *.TXT

displays all text files, while

DIR A???B.*

displays a list of all files that have a five-character name where the first letter is A and the last letter is B.

Another command is ERA, which is short for Erase. You use this to erase a file from the disk. For example,

ERA MYLETTER.TXT

erases the file with that name, while

ERA *.TXT

erases all text files. Erasing a file means freeing the directory entry and the disk space occupied by the file.

Another command is REN, which is short for Rename. You use this command to change the name of a file. The TYPE command displays the contents of a text file. Because a text file contains only ASCII codes, this command allows you to read a file right on the screen, like this:

TYPE MYLETTER.TXT

The SAVE command saves one or more 256-byte memory blocks located in the Transient Program Area to a disk file with a specified name.

If you type in a command that CP/M doesn't recognize, it assumes you're specifying the name of a program that's stored as a file on the disk. Programs always have the file type COM, which stands for Command. The CCP searches for a file of that name on the disk. If one exists, CP/M loads the file from disk into the Transient Program Area, which begins at memory address 0100h. This is how you run programs that are located on the disk. For example, if you type

CALC

following the CP/M prompt, and if a file named CALC.COM exists on the disk, the CCP loads that file into memory starting at address 0100h and then executes the program by jumping to the machine-code instruction located at address 0100h.

Earlier I explained how you can insert machine-code instructions any-where into memory and execute them, but in CP/M programs that are stored in disk files must be designed to be loaded into memory beginning at a specific memory location, which is 0100h.

CP/M comes with several useful programs, including PIP, the Peripheral Interchange Program, which allows you to copy files. The ED program is a text editor that allows you to create and modify text files. Programs such as PIP and ED, which are small and designed to do simple chores, are often known as utility programs.

Return Main Page Previous Page Next Page

®Online Book Reader