OMAIN.DOC 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. The overlay system from Topspeed version 1 has been supplied for your
  2. convenience. If you have used the system with version 1 there are several
  3. things you have to look out for.
  4. Modules which are part of an overlay must not contain any initialization code
  5. "(*# module(init_code=>off) *)" must be specified in both definition and
  6. implementation part of the module.
  7. The linker must no be allowed to pack segments.
  8. "#pragma link_option(pack=>off)" must be specified in the project file.
  9. Programs using overlays must be compiled in XLarge or MThread model.
  10. Modules with initialization code which are used by an module in an overlay
  11. must be initialized before code in the overlay is called. This can be achieved
  12. by copying the import list from the module in the overlay into the module
  13. where the overlay is loaded.
  14. The following is an anotated listing of the omain overlay example.
  15. omain.pr ----------------------------------------------------------------------
  16. #set model = "xlarge"
  17. #set system = "dos"
  18. #set linkopt = "case=>off"
  19. #set lang = "mod"
  20. #include basic.pi
  21. #pragma link_option(pack=>off) -- linker must not pack segments.
  22. -- overlay system will not work if this hapens
  23. -- and no warnig will be given
  24. #pragma link(%jpilib)
  25. #compile omain
  26. #autocompile
  27. %dolink
  28. #if %make="on" #then
  29. #run "ovl omain" -- run ovl program to split into overlays.
  30. #endif
  31. %doend
  32. omain.ovl ----------------------------------------------------------------------
  33. 1 OP1_TEXT -- put code from module op1 in overlay 1
  34. 2 OP2_TEXT -- put code from module op2 and op3 in overlay 2
  35. 2 OP3_TEXT
  36. omain.mod ----------------------------------------------------------------------
  37. MODULE omain;
  38. (*%F _fdata*) Make program in XLarge or MThread model (*%E*)
  39. IMPORT ovl117,op1,op2,op3;
  40. IMPORT IO; (* IO is used in op1-op3, and therefore must be initioalized
  41. before op1-op3 are used ,this import enshures this *)
  42. PROCEDURE x;
  43. BEGIN
  44. ovl117.Load(1);
  45. op1.p1;
  46. ovl117.UnLoad(1);
  47. ovl117.Load(2);
  48. op2.p2;
  49. op3.p3;
  50. ovl117.UnLoad(2);
  51. END x;
  52. BEGIN
  53. x;
  54. END omain.
  55. op1.def ----------------------------------------------------------------------
  56. (*# module(init_code=>off) *)
  57. (* overlayed modules are not allowed to have initcode *)
  58. DEFINITION MODULE op1;
  59. PROCEDURE p1;
  60. END op1.
  61. op1.mo ----------------------------------------------------------------------
  62. (*# module(init_code=>off) *)
  63. (* overlayed modules are not allowed to have initcode *)
  64. IMPLEMENTATION MODULE op1;
  65. IMPORT IO;
  66. PROCEDURE p1;
  67. BEGIN
  68. IO.WrStr('procedure p1 in op1');
  69. IO.WrLn;
  70. END p1;
  71. END op1.
  72. op2.def ----------------------------------------------------------------------
  73. (*# module(init_code=>off) *)
  74. (* overlayed modules are not allowed to have initcode *)
  75. DEFINITION MODULE op2;
  76. PROCEDURE p2;
  77. END op2.
  78. op2.mod ----------------------------------------------------------------------
  79. (*# module(init_code=>off) *)
  80. (* overlayed modules are not allowed to have initcode *)
  81. IMPLEMENTATION MODULE op2;
  82. IMPORT IO;
  83. PROCEDURE p2;
  84. BEGIN
  85. IO.WrStr('procedure p2 in op2');
  86. IO.WrLn;
  87. END p2;
  88. END op2.
  89. op3.def ----------------------------------------------------------------------
  90. (*# module(init_code=>off) *)
  91. (* overlayed modules are not allowed to have initcode *)
  92. DEFINITION MODULE op3;
  93. PROCEDURE p3;
  94. END op3.
  95. op3.mod ----------------------------------------------------------------------
  96. (*# module(init_code=>off) *)
  97. (* overlayed modules are not allowed to have initcode *)
  98. IMPLEMENTATION MODULE op3;
  99. IMPORT IO;
  100. PROCEDURE p3;
  101. BEGIN
  102. IO.WrStr('procedure p3 in op3');
  103. IO.WrLn;
  104. END p3;
  105. END op3.
  106. Using Overlays in Modula-2 Programs:
  107. ====================================
  108. This section contains a brief description of the system
  109. available for creating and using overlays.
  110. Please Note: This bit of software was designed and
  111. implemented for internal use by JPI. It is not user
  112. friendly and any mistakes you make will probably crash your
  113. machine hopelessly. It is however flexible and efficient.
  114. There are two components: OVL is used to split an EXE-file
  115. into overlays. The Overlay module is used in the running
  116. program, to read in the overlays.
  117. In order to give you maximum flexibility, OVL.MOD, the
  118. program which makes overlays, is provided in source form.
  119. As a first step, you should compile and link the OVL
  120. program itself.
  121. The OVL program modifies your EXE-files to enable you to
  122. use overlays for the program. An Overlay consists of a set
  123. of complete segments, which are not loaded initially, but
  124. which can be brought in by the call.
  125. Overlay.Load(n)
  126. where Load is a predefined procedure in the Overlay module
  127. included in the Techkit. (The module also contains the
  128. procedure UnLoad, for removing an overlay from memory).
  129. You can have more then one overlay loaded at a time (if
  130. Space permits).
  131. The parameter, n, is the number of the overlay to load, and
  132. must be in the range, 1..9. After being loaded, all
  133. procedures in that overlay may be called as normal.
  134. Overlay.Load calls Storage.HeapAllocate to obtain the
  135. memory for the overlay.
  136. Thus, the overlay module makes it possible to move overlays
  137. into and out of your program.
  138. To create the overlay(s), you need to do several things.
  139. Suppose your program is called FRED. Make the porgram as
  140. normal, then create a text file, FRED.OVL, with one line for
  141. each segment or group you wish to put in an overlay. The format
  142. of each line is a number from 1-9, followed by the group
  143. name (or segment name if there is no group name).
  144. For example, suppose you want to overlay modules FRED1 andFRED2 into
  145. one overlay and FRED3 into another. The
  146. FRED.OVL file would contain the following:
  147. 1 G_FRED1
  148. 1 G_FRED2
  149. 2 G_FRED3
  150. The command to create the overlays and to modify FRED.EXE
  151. is
  152. ovl fred
  153. This reads the FRED.OVL file, and creates the appropriate
  154. overlay File(s).
  155. The overlays will be in files FRED.OV1, FRED.OV2..FRED.OV9.
  156. Bear in mind that it is the program's responsibility to
  157. load the overlays. The map is modified to include only
  158. resident code, and the old map is copied to FRED.OMP.
  159. Handling Small Segments Properly
  160. There is a slight flaw in the concept where segments are
  161. less than one paragraph, because this means that the OVL-
  162. program cannot distinguish the segment to which a segment
  163. fixup applies. Thus, if two segments in different overlays
  164. have the same paragraph, chaos will result.
  165. This means that, to be safe, all segments should be at
  166. least one paragraph. The OVL program issues a warning
  167. whenever this is a problem. If this happens you should
  168. enlarge the segment to at least 16 bytes by adding some
  169. extra variable declarations.
  170. Initialising code also tends to cause problems. In this
  171. case, the simplest solution is to use explicit procedure
  172. calls for modules which are non-resident, and then execute
  173. these (after loading the overlay) from another (resident)
  174. module's initialisation.
  175.