!lm11
!rm76
Hiding Things Under DOS..........................Rick Hatcher

In issue number 5/1980 of NIBBLE, a small article by William Reynolds III tells how to do something I have wondered about for a long time.  That is how to move the HIMEM pointer down so that machine language code or something else can be put out of the way and protected.  For example:  I have a lower-case routine I like to use on key input; I also like to use the character display routine from Lawrence Hall of Science which is hooked into the control-Y pointer.  This is one way to dump memory in both hex and ASCII.  I have looked for protected areas but until now the only place seemed to be from $300 to $3CF.  This is a little over 200 bytes, and I needed about 400.

Neil Konzen's Program Line Editor (from Call A.P.P.L.E.) moves the file buffers down and leaves space between the buffers and DOS...but the manual which I sneaked a look at does not tell how to do it.  The article in NIBBLE on page 40 finally revealed the secret.  The file buffers are located by a pointer at locations $9D00 and $9D01 (least significant byte first, as usual).  A DOS routine at $A7D4 builds the buffers using this pointer and the value of MAXFILES (at $AA57).  [note: all addresses assume a 48K system]

All you have to do is change the address at $9D00.9D01 and call the routine at $A7D4.  I wanted to create a space of $200 bytes (512 decimal).  The normal value at $9D00.9D01 is $9CD3.  I changed it to $9AD3, and then typed A7D4G in the monitor.  The value of HIMEM was automatically changed to $9400 from the usual $9600.  The protected area is from $9B00 to $9CFF.  The buffers are located from $9400 to $9AFF and DOS is located from $9D00 to BFFF.  If a MAXFILES command is used it changes HIMEM but the buffer top at $9AFF stays unchanged.

To make space like this from an Applesoft program, here is all you need:

     100 POKE 40193,154
     110 POKE 40192,211
     120 CALL 42964

It isn't so easy in Integer BASIC, because the routine moves HIMEM without moving the program down in memory. (Remember Integer BASIC programs are at the top of memory up against HIMEM; Applesoft programs are at the low end of memory.)  The NIBBLE article gives a method for Integer BASIC, but I haven't tried it.

I use an Applesoft HELLO program which first does the three lines above, and then BRUNs or BLOADs the code I want to hide.  The BRUN portion sets up the I/O hooks at $36.39 and sets up the control-Y vector at $3F8.  I use the BLOAD if I want the code resident but not hooked in.

Once the space is made, it stays there.  If you INIT a slave disk, the slave has the same change.

The NIBBLE article reveals a few more details about the buffers in which you may be interested.
