15. The PME software - 766 bytes of text editor

The new PM Editor was introduced in chapter 13. Now that we know how to ‘drive’ the new software, it may be interesting to take a good look ‘under the bonnet’ to find out how the ‘engine’ works — byte by byte. The program is based partly on existing subroutines and partly on totally new subroutines which, as always, can be incorporated into user programs. Although the PME program contains relatively few bytes compared to the rest of the software in this book, each routine will be dealt with and fully explained in turn.

  1. Let us start by looking at PME in general. As an aid to this, a block diagram has been drawn and is illustrated in figure 1. PME is structured as follows:

    The main routine is preceded by an initialisation routine which is only run now and again. As can be seen from the flowchart, PME originates from three sources, much in the same way as a river is formed by the convergence of a number of brooks and streams. The three sources are: the cold, warm CEND and lukewarm start entry routines. A fourth ‘tributary’, the ASSEND routine, should really be considered as an intermediate routine which is instigated by the depression of the ‘ST’ key on the main keyboard.

    Normally, any use of PME will lead to its main routine, which is everything after the WARM label in figure 1. The procedure carried out by this main routine should be very familiar by now. Once a depressed key has been detected, the program carries out an interrogation procedure to find out which key was depressed: was it the ‘A’ key? If so, carry out the ‘A’ key routine. If not, was it the ‘B’ key? If so, execute the ‘B’ key routine. If not, was it the ‘C’ key? etc. After executing the corresponding key routine, the program returns to the central label WARM of the main PME routine, where the computer waits for a new key to be depressed and then the Subsequent key operation is carried out, and so on. Sometimes the computer will return to the WARM label via a ‘half-way’