Msg: 4640 *Conference*

08-31-93 10:32:13

From: TRACY ALLEN

To : CARROLL LEWIS

Subj: REPLY TO MSG #4626 (CO'S)

Dear Carroll,
  When you run a CO program from the menu or using the RUNM" or LOADM" commands
in BASIC, the program code gets loaded from its passive residence in low
memory, up to its active residence at the high end of memory.  The ususal place
for CO programs is between the addresses HIMEM and MAXRAM.  When you change the
value of HIMEM, the computer moves its stack, file buffers and string storage
area to just below the address HIMEM.  Let's The computer puts your program
between HIMEM and MAXRAM.  (Some small CO programs use small pockets of memory
that are available elsewhere in the area of memory above maxram).  If you
subsequently run a different CO program, it can load in on top of the one that
was there before.  Yes, if there are two copies of your CO program -- one at
its passive location in low memory as a CO file, the other at its active
location in high memory.    
  
  The problem of cold starts doesn't come from having one CO program load in on
top of another in that high memory space.  For example, one CO program can do a
job and quit, and then another can be loaded into the same space and do it's
job and quit without a trace of a problem.  The problem comes from "hooks" that
are left in place by one program.  Let's say a BASIC program LOADMs some
machine language code, and then uses CALL statements to adresses where that
code is loaded.  Obviously, if you load in some other machine language program
over top of the first one and then attempt to use the original CALL addresses,
you are asking for trouble.   In a similar vein, CO programs themselves install
CALLs to themselves into the system HOOK table.  For example, the program can
force the computer to call a certain address 256 times a second, whenever the
hardware clock interrupt occurs.  The computer does that faithfully, jumping to
that certain address 256 times per second.  The program at that point does
something like look at the keyboard for special character processing or running
a stopwatch or whatever.  But what happens if a different program gets loaded
into that spot?  The computer still jumps to that certain address, but what it
runs is a random program that can do anything to memory, rnaging from subtle
changes to files, to instantaneous ice-downs.   The moral is, before loading a
new CO program, disable the hooks.  There are a lot of other hooks that allow
the CO program to respond to events within the computer:  key pressed: data
sent to screen, to printer, powerdown, powerup, warm start, etc.
  
  So the problem you face isn't so much clearing space for the next CO program,
as it is understanding what hooks the previous program is leaving behind.
  -- Tracy