home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / asmutl / maksrl.lbr / MAKSRL.DQC / MAKSRL.DOC
Encoding:
Text File  |  1986-11-29  |  3.8 KB  |  101 lines

  1.  
  2.                                   MAKSRL
  3.                                  04/22/85
  4.                                     RDL
  5.  
  6.  
  7.      The MAKSRL package allows you to create a self-relocating program,
  8. that is, a program which automatically relocates itself to high memory upon
  9. beginning execution.
  10.  
  11.      There's been a scad of ways used at one time or another to produce COM
  12. files which, when executed, will determine where high memory is, then
  13. relocate the bulk of the code into the highest possible memory location for
  14. execution.  The most difficult example I've come across is in BYE, which
  15. has a whole section devoted to examining its own code to determine which
  16. bytes must be modified.
  17.  
  18.      MAKSRL automatically produces a COM file which does the whole thing
  19. with practically no fuss at all.  The whole process comes down to creating
  20. an M80 source file which expects to execute in high memory, then typing
  21. either SUBMIT MAKSRL <name>, or (in Tdos) DO MAKSRL <name>.  For example,
  22. to create FOOBAR.COM from FOOBAR.MAC, type SUBMIT MAKSRL FOOBAR.
  23.  
  24.      Whichever batch file you use on your system, it will assemble your
  25. source with M80, then invoke L80 twice to create the two object files which
  26. MAKSRL.COM uses as input.  Finally, the batch procedure will invoke
  27. MAKSRL.COM and delete all intermediate files.
  28.  
  29.      MAKSRL.COM is invoked with a file-name header which identifies the two
  30. input files and the destination file.  If both input files are found,
  31. MAKSRL creates <hedr>.COM which contains the code from <hedr>.REL and a
  32. loader which relocates the code to high memory.  As an example, the command
  33. MAKSRL FOOBAR will create FOOBAR.COM from the input files created earlier
  34. by the batch file.
  35.  
  36.      Writing your program is very straightforward.  Just make sure the
  37. program counter is set to CSEG, then jump right in with your code.  From
  38. the first line, what you're writing will eventually execute in high memory.
  39. If you're writing a module which is to remain memory resident, you can put
  40. any initializations, including the code which sets up the BIOS and BDOS
  41. pointers, just before a BDOS jump-around vector, so that the inits do not
  42. stay memory resident.  (See example below.)
  43.  
  44.      MAKSRL is loosely based on and heavily modified from the MAKELUX
  45. program in LUX40.LBR which creates LUX.COM.
  46.  
  47.  
  48.  
  49.            SAMPLE CODE FOR A MODULE WHICH WILL BE CORE RESIDENT:
  50.  
  51. ;
  52. ;       INITS
  53. ;
  54.         CSEG
  55. ;
  56.         LHLD    6               ;GET ACTUAL BDOS ENTRY
  57.         SHLD    JBDOS+1         ;SAVE IN JUMP-AROUND VECTOR
  58.         LXI     H,JBDOS         ;SET TOP MEM PTR TO PROTECT CODE
  59.         SHLD    6
  60. ;
  61.         LHLD    1               ;SET UP TO TRAP WARM STARTS
  62.         INX     H               ;SAVE ACTUAL WARM START VECTOR
  63.         MOV     E,M
  64.         INX     H
  65.         MOV     D,M
  66.         XCHG
  67.         SHLD    WRMSAV
  68.         LXI     H,FAKEWM        ;SET LOCAL WARM START VECTOR
  69.         XCHG
  70.         MOV     M,D
  71.         DCX     H
  72.         MOV     M,E
  73. ;
  74.         JMP     START           ;GO TO PROGRAM BEGINNING
  75. ;
  76. JBDOS:  JMP     $-$             ;BEGINNING OF RESIDENT CODE
  77. ;
  78.  
  79. Here, in the body of your program, include code at FAKEWM to do whatever
  80. you want to do when a warm start occurs.
  81.  
  82. ;
  83. ;       CODE TO REMOVE THE MODULE WHEN NO LONGER NEEDED
  84. ;
  85. QUIT:   LHLD    JBDOS+1         ;RESTORE ACTUAL BDOS POINTER
  86.         SHLD    6
  87. ;
  88.         LHLD    WRMSAV          ;RESTORE BIOS WARM START
  89.         XCHG
  90.         LHLD    1
  91.         INX     H
  92.         MOV     M,E
  93.         INX     H
  94.         MOV     M,D
  95. ;
  96.         JMP     0               ;GO WARM START
  97. ;
  98. WRMSAV: DW      0               ;STORAGE FOR WARM START VECTOR
  99. ;
  100.         END
  101.