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

Sign up to get new articles straight to your inbox.

Delivered by FeedBurner

Related Articles

I Love ED on CP/M

I love ED on CP/M. It's often derided but I think it's just misunderstood and with a little practise its true value can shine through. It's elegant, easy to learn and only has about 25 commands but t...   Read More

The Pilot Programming Language on CP/M

Pilot was created by John A. Starkweather in the early 1960s as a programming language for Computer Assisted Instruction. It has often been compared to Logo because of its use with children. However,...   Read More

Image Viewers on CP/M

CP/M is by default a text-only affair. However, many of the machines that can run CP/M have hardware that would allow them to display graphics. As BBSing started to grow so too did the distribution o...   Read More

The Mouse Programming Language on CP/M

Mouse is an interpreted stack orientated language designed by Peter Grogono around 1975. It was designed to be a small but powerful language for microcomputers, similar to Forth, but much simpler. On...   Read More

DABAR: A Hebrew Vocabulary Drill System on CP/M

I recently came across an interesting program called DABAR to drill Hebrew vocabulary. The program works in a similar way to flash cards, by displaying a word in Hebrew and then asking for its English...   Read More