  Turbo 5.0/4.0 stay-resident demonstration package 

   TP-TSR                 2/11/89                Richard W. Prescott

   This package illustrates a method for writing TP4/5 interrupt 
   routines with sufficient power and flexibility to support 
   sophisticated resident applications.  The interrupt hook and 
   return procedures are written in assembly language, however the 
   remainder of the application can be written entirely in Pascal, 
   can use up to 64K stack, and can Chain or Return from Interrupt 
   from any point in the Pascal Code.  All source code is provided, 
   and all assembly source code is contained in the Units CONSOLE and 
   DOS21_0A which are provided in both source and compiled form.  
   Users without an assembler can redesign everything but the 
   interrupt hook and return procedures.  


   Files provided in this package:

   README         (This file)
   DOS21_0A.PAS   Interrupt Unit (Pas/Asm Source)
   DOS21_0A.TPU   Interrupt Unit (Compiled w Turbo Version 5.0)
   DOS21_0A.TP4   Interrupt Unit (Compiled w Turbo Version 4.0)
   CONSOLE.PAS    CRT-type Procedures & Functions (Pas/Asm Source)
   CONSOLE.TPU    CRT-type Procedures & Functions (Compiled w Turbo 5)
   CONSOLE.TPU    CRT-type Procedures & Functions (Compiled w Turbo 4)
   CPATH.PAS      Simple resident program (Pascal Source)
   CPATH.EXE      Simple resident program (Compiled)
   CMDQ.PAS       Command editor program (Pascal Source)
   CMDQ.EXE       Command editor program (Compiled)


   The sample interrupt Unit provided installs an interrupt handler 
   for the DOS function 0Ah (Buffered Input), which is the function 
   used by COMMAND.COM and DEBUG.COM to request keyboard input.  
   Routines are provided to return (IRET) to the calling program or 
   to Chain to the next program in the interrupt chain.  These 
   routines can be invoked from any point in the service routine.  
   Simple and obvious modifications can be made to the interrupt unit 
   to create handlers for other functions and/or interrupts.  

   The programs CPATH and CMDQ provide concrete examples of resident 
   programs using the DOS21_0A Interrupt Unit.  CPATH is the shortest 
   program I could think of which nonetheless uses the interrupt unit 
   to do something at least slightly useful.  It checks the current 
   disk drive, and if it is 'C' or greater, writes the current 
   directory path (e.g.  C:\TURBO> ) before chaining to the original 
   interrupt routine to service the input request.  The advantage 
   over the $p $g method described on p595 of the Turbo 4.0 Owner's 
   Handbook and on p317 of the Turbo 5.0 User's Guide is that CPATH 
   does not cause the noticable pause between each DOS command when 
   the active drive is a floppy disk drive.  It assumes that most 
   users do not use subdirectories on their floppy disks.  

   CMDQ is a more ambitious undertaking which provides all the 
   features of a basic command line editor with command recall.  It 
   is written in a modular fashion and is heavily commented so that 
   you may easily customize it to your liking.  The basic edit key 
   configuration is compatible with CED by Chris Dunford and NDOSEDIT 
   by Jack Gersbach:  use the Up Arrow to move back through previous 
   commands, and Down Arrow to move forward again.  While any command 
   is displayed, use Home, End, Left, Right, Ctrl Left, and Ctrl 
   Right to move around, and Esc, Ctrl Home, Ctrl End, Backspace, and 
   Delete to delete all or part of a line.  Insert toggles between 
   insert and overwrite mode, and Enter, from any position on the 
   line, executes the command.  Refer to the comments in CMDQ.PAS for 
   a further description of what each key does.  

   Note that neither CPATH nor CMDQ could be written using the built-
   in "Interrupt Procedure" provided in Turbo version 4/5, since it 
   does not provide for chaining to the previous interrupt vector.  

   For those interested in designing interrupt units for other 
   applications, two features of the present unit are worth noting.  
   First, since it is impossible for DOS to be active at the time of 
   the interrupt which results in a call to our Pascal code, we can 
   make full use of DOS functions (including WRITELN, FindFirst, etc) 
   within the Pascal code of the service routine.  Handlers for 
   interrupts other than $21 must either insure that DOS is not 
   active when they "wake up", or avoid using DOS function calls 
   within the handler.  Second, since these programs are active at 
   EVERY function 0A request, there is no need for a separate 
   Interrupt $16 or $09 routine to check for a "Hot Key".  Programs 
   which do install more than one interrupt handler must provide a 
   separate stack area for each handler, or use the caller's stack.  

   The Units CONSOLE and DOS21_0A were compiled and assembled using 
   Turbo Pascal Version 5.0 and TP&Asm Version 2 .  TP&Asm provides 
   an integrated compile-time assembler within the Turbo development 
   environment (and the command line compiler TPC).  The result is an 
   ASSEMBLY Development Environment which is identical to your PASCAL 
   Development Environment, and which allows you to mix assembly 
   language sections freely within your Pascal code and to make 
   simplified assembly references to all Pascal variables.  It 
   provides fast assembly with no additional disk access, and reports 
   assembly syntax errors on the standard Turbo error line with 
   cursor placed on the error.  It accepts the standard syntax of 
   both MASM and A86, but also provides certain enhancements such as 
   the placement of named data in the Code Segment which is used in 
   the interrupt unit DOS21_0A.  

   TP&Asm Version 2.0 will be available from me for $49 plus $3 P&H.  
   The current Beta Test Version 2  is available now for $39 plus $3 
   P&H, with a free upgrade to 2.0 when it becomes available.  

   A sharable Memory Mode version called TP&Asm-M is also available.  
   TP&Asm-M provides the same assembly language capabilities as TPA, 
   but is intended only for assembly language development within the 
   Turbo 4.0 or 5.0 integrated environments, and therefore does not 
   have the capability of compiling to disk.  (You can of course read 
   and save Pascal and Assembly SOURCE files with both programs).  

   The TP&Asm-M distribution disk can be ordered from me for $5 plus 
   $3 P&H, with the $5 being credited toward subsequent registration 
   of TP&Asm or TP&Asm-M.  It can also be downloaded from the IBMPRO 
   or BPROGA forums on CompUServe.  Look for TPA2-A.ARC and TPA2-R.ARC.


   To order TP&Asm, please send a check or money order payable to:

                         Richard W. Prescott
                         724 Sauk Ridge Trail
                         Madison, WI  53705

   Please include the following information:

   1. Full Version number of the Turbo Pascal compiler you now use.

   2. Your registration number for that compiler.

   3. If you obtained TP&Asm-M from a bulletin board:
      3a. Area code and phone number of that bulletin board
      3b. Full Version number of the TP&Asm-M version you have
      3c. Directory Date of the README file


   The source and compiled code in this package is copyrighted as 
   indicated.  You may share this package and/or upload it to 
   bulletin boards as long as no fee is charged.  You may of course 
   make modifications to these programs for your own use, and you may 
   distribute these modifications with the package.  The original 
   unmodified files must all be present.  

   Registered owners of TP&Asm may distribute programs using any of 
   the source code or compiled units in this package in original or 
   modified form.  Please give appropriate credit.  

   If you distribute programs written using TP&Asm, please help me 
   spread the word by including a statement like the following: 

          This program was compiled and assembled using 
         Turbo Pascal Version xxx and TP&Asm Version yyy.  

