The Last Word 3.0 Reference Manual
12-71
12 PROGRAMMER'S TECHNICAL NOTES
This section first outlines LW's memory map, then goes on to discuss some of the
general ideas behind the program. It isn’t a guide to writing extensions for LW (please
refer to the extension developer’s documentation). If you're having problems running
LW, you'll want to check out the section on memory usage. I'll also be talking about
various tricks that LW employs, and why it has turned out the way it has.
12.1 ASSEMBLY LANGUAGE ADD-INS
From version 2.1 onwards, LW has presented assembly language programmers with
the interesting opportunity to writing their own machine code routines to extend the
functionality of the software. These pure machine code files must adhere to strict
guidelines, and are (as of version 3) only available when using extended RAM. Add-ins
(or extensions) are loaded at $3300 and can be up to 3K in size. They can hook into
editor keystrokes, the reset routine, the print formatter, etc, and potentially provide
anything from a character map to a spelling checker.
A toolkit for writing add-ins is available with the retail version of The Last Word, and
will include a full equate list for the program, example add-ins, code samples, and
guidelines for writing your own modules.
12.2 MEMORY USAGE
Although the LW.EXE executable is over 31K long, about 4K is initialisation code
which is jettisoned once the program is up and running. 14K of the program code goes
straight under the OS ROM between $C000-$CFFF and $D800-$FFFF, and memory
between $2000 and $3200 is a mixture of program code, data and buffers. When using
BANKED memory, the main text buffer occupies memory from $3300-$7FFF
(depending on the size of the add-in buffer which resides at $3300 when active), and
the $4000-$7FFF area is a window onto any text buffers which reside in banked
memory. When banked memory is turned off, the main text buffer occupies the area
$4000-$7FFF, $3300-$3FFF being used by internal buffers.
LW also uses several other regions for data storage, including the entire upper half of
page zero ($80-$FF). ALL memory from $3FD to $6FF is used by LW for buffers. This
area includes the OS cassette buffer, which you're (hopefully) unlikely to need. Note
that it’s no longer possible (as of version 3.0) to re-enter LW using “Run at Address”
from the DOS menu. This is because the program unhooks itself completely from
beneath the OS ROM when you exit to DOS.
You should ensure that no resident handlers use memory from $400-$6FF, otherwise
conflicts with LW will certainly occur. Similarly, and TSRs or resident handlers must not
extend about $2000. SpartaDOS X set-ups can provide very low MEMLO values which
can allow for resident handlers to be installed. However, with DOS 2.5 systems,
there’s unlikely to be any room for additional sector buffers, etc.
One of LW’s largest memory demands is for the 80 column screen display, which
consumes about 9K of RAM. For this reason, it has proved quite a feat to shoe-horn all
of LW’s functionality into the remaining memory space. Even so, LW still remains true
to its original remit: that it should run on an unexpanded 800XL.