Re-execute Programs in Memory on CP/M

After a transient program terminates on CP/M it's often possible to re-execute it in memory without having to reload it from disk. This is a great little trick if using slow disks as it's much quicker to just jump back into memory. It's also useful because it could prevent you from losing work if you exited a program without saving.

Creating the Re-execute Command

The re-execute command is the smallest possible command. It is simply an empty .COM file. We can easily create an empty file called 'RERUN.COM' using the resident 'SAVE' command:

SAVE 0 RERUN.COM

Using the Re-execute Command

Under CP/M, programs that load from disk are referred to as Transient Programs and these run in an area of memory called the Transient Program Area (TPA) starting at location 0100h. A transient program is normally run from the command line by the Console Command Processor (CCP) located above the TPA. When a transient program finishes it generally returns control to the CCP. This is often done by initiating a warm start by jumping to location 0000h.

After we have exited a program we can re-execute it by running the 'RERUN' command we created earlier. This would cause the CCP to load it into the TPA and jump to its start at 0100h. However, because the 'RERUN' command is empty it doesn't write over the existing program in the TPA and instead starts executing it from the start. This won't always work though as often programs won't reinitialize their variables when a program starts or they may write over the CCP in which case reloading it would corrupt this part of the program. Therefore, it takes a certain amount of trial and error to find which programs this will work for.

Example

Below we demonstrate this by entering a program into TINY BASIC, exiting from Basic (using BYE), running RERUN to re-execute Basic and then seeing that the Basic program is still intact in memory. This would be very useful if we forget to save our entered Basic program as we could jump back into it and then save it.

D>TINYBAS

SHERRY BROTHERS TINY BASIC VER. 3.1

OK
>10 FOR I=1 TO 5
>20 PRINT "HELLO WORLD!"
>30 NEXT I
>BYE

D>RERUN

OK
>LIST
  10 FOR I=1 TO 5
  20 PRINT "HELLO WORLD!"
  30 NEXT I

OK
>RUN
HELLO WORLD!
HELLO WORLD!
HELLO WORLD!
HELLO WORLD!
HELLO WORLD!

OK
>

CP/M Plus

This procedure won't work on CP/M Plus as during a cold or warm start it overwrites the start of the TPA with the CCP and therefore if we were to run our 'RERUN' command it would just jump to the CCP and continue executing.

Video

The following video shows the re-execute command being used.

Creative Commons License
Re-execute Programs in Memory on CP/M by Lawrence Woodman is licensed under a Creative Commons Attribution 4.0 International License.

Share This Post

Feedback/Discuss

Related Articles

Modula-2 Compilers on CP/M

Modula-2 is a great language in general and is a good choice for programming on CP/M. There are three good compilers available for CP/M which all require a Z80 processor and we'll compare each in turn...   Read More

XCCP: A Shell Extension for CP/M

XCCP describes itself as an Extended Console Command Processor for CP/M. It supports the 8080 and v1.0 was released by Anton R. Fleig in 1984. Like EPEX, XCCP doesn't require installing so we can begi...   Read More

EPEX: An Environment Extension for CP/M

Epex is an evironment extension for CP/M. It stands for Environmental Processing EXecutive, and v1.1 was released by James H. Whorton in 1986. It can make using CP/M much more comfortable at the cost...   Read More

File Comparison Utilities on CP/M

There are many utilities available for CP/M to compare the differences between files and to distribute those differences. All the utilities in this article can be found on the Walnut Creek CD. Binary ...   Read More

Breakout Style Games on CP/M

Breakout style video games were pretty popular at one time both at Arcades and on home computers. The games are based on a simple concept where you have to destroy a group of 'bricks' at the top of t...   Read More