home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / arrays / arr_v110 / largearr.txt < prev    next >
Encoding:
Text File  |  1991-03-13  |  9.8 KB  |  280 lines

  1. LARGE, VIRTUAL AND HUGH ARRAYS Version 1.1
  2. by Graham Robertson
  3.  
  4.  
  5. The software enclosed has three parts.
  6.  
  7. 1.  Large Arrays (Arrays up to the size memory allows)
  8. Procedures are written in machine code to allow the use of large arrays in 
  9. a C program. The array can be of any size as long as memory permits.
  10.  
  11. 2.  Virtual Arrays and Hugh Arrays (Arrays up to the size of your DISK or 
  12.     VDISK)
  13. Procedures which include the code from part one but allow many large 
  14. arrays to be accessed. If there is no space left then old arrays will 
  15. cached to the disk or a virtual disk. Several virtual arrays can be used 
  16. to create one hugh array of any size. This restricted version limits the 
  17. number of virtual arrays to sixteen.
  18.  
  19. 3.  Version 1.1 of this software also allows your extended memory to be 
  20.     accessed directly for this system.
  21.  
  22. ---------------------------------------------------------------------
  23.  
  24. This software is copyright British Software Licensing 1991. The usual 
  25. disclaimers apply.
  26.  
  27. The number of virtual arrays is restricted to sixteen in the unregistered 
  28. version.
  29.  
  30. If you use this software please send 6 pounds to British Software 
  31. Licensing.
  32. If you require a version which allows unrestricted virtual arrays please 
  33. register your copy of this software. 
  34. A copy of the source code can be obtained by sending 15 pounds to British 
  35. Software Licensing.
  36.  
  37. If you use this software in any other Shareware or commercial application 
  38. please contact the author to make arrangements.
  39.  
  40.  
  41. ----------------------------------------------------------------------
  42. Order Form
  43. -----------------------------------------------------------------------
  44. To  British Software Licensing
  45.     280 (T/L) West Princes Street,
  46.     Woodlands,
  47.     Glasgow
  48.     United Kingdom
  49.     G4 9EU
  50.  
  51. please supply me with:
  52.  
  53. an unrestricted copy of the large array manager     [   ]   5 pounds
  54.  
  55. a copy of the source for the virtual array manager
  56. excluding the extended memory source code           [   ]  15 pounds
  57.  
  58. a copy of the source for the virtual array manger
  59. including the extended memory source code           [   ]  25 pounds
  60.  
  61. overseas shipment                                   [   ]  2 pounds
  62.                                                  -------------------
  63. Total payment
  64.                                                  -------------------
  65.  
  66.  
  67. Payment type  ACCESS/VISA/MASTERCARD/CHECK(u.k. pounds)/POSTAL ORDER
  68.  
  69. Name on Card  ____________________________________
  70.  
  71.  
  72. Card Number   ____________________________________
  73.  
  74.  
  75. Expiry date   ____________________________________
  76.  
  77.  
  78. Signature of Cardholder  ___________________________________
  79.  
  80. ------------------------------------------------------------------
  81.  
  82. You may also purchase this software from:
  83. Graham Robertson on
  84.                              041-339-8855x5021
  85. or on an Answering Machine   041-339-7264
  86. or via Email       Graham.J.S.Robertson@uk.ac.glasgow.vme
  87. or from America    Graham.J.S.Robertson@vme.glasgow.ac.uk
  88. quoting the details required above.
  89.  
  90.  
  91. -------------------------------------------------------------------
  92. Files in the package.
  93.  
  94. LARGEARR.H         - Prototype of procedures used for large arrays
  95.  
  96. ARRAY.C            - Source code of an example of using a large array
  97. ARRAY.EXE          - Example of using a large array
  98.                    Compiled ARRAY.C linked with VIRIMG.LIB
  99.  
  100. VIRIMG.LIB         - Software to allow virtual and large arrays 
  101.  
  102. VIRIMG.H           - Prototypes of procedures for creating virtual arrays
  103.  
  104. VIRARRAY.C         - Source code of an example of using virtual arrays
  105. VIRARRAY.EXE       - Example of using virtual arrays
  106.                    Compiled VIRARRAY.C linked with VIRIMG.LIB
  107.  
  108. HUGHARR.C          - Source code of an example of using a hugh array
  109. HUGHARR.EXE        - Example of using a hugh array
  110.  
  111. XMSARRAY.ZIP       - The same files as above, but using extended memory
  112.                      instead of caching to disk.
  113.  
  114. -------------------------------------------------------------------
  115. All the code here is compiled using the large data model
  116. -------------------------------------------------------------------
  117.  
  118. Part 1 Using large arrays
  119. -------------------------
  120.  
  121. This software is much use by example, so the comments in this document 
  122. mainly explain the procedures that have been developed to enable the use 
  123. of large, hugh and virtual arrays.
  124.  
  125. ---------
  126.  
  127. There is only one procedure needed for accessing large arrays which adds 
  128. an offset to a void pointer and returns a void pointer. The prototype is 
  129. as follows.
  130.  
  131.     void *pointer_add (void *ptr,long offset)
  132.  
  133. The result of this is :- result = ptr+offset.
  134.  
  135. This routine is written is machine code so is very fast.
  136.  
  137. As can be seen in the program LARGEARR.C, to access an array, a macro is 
  138. defined as follows.
  139.  
  140. #define <array in low>(x) ((<data type>*)pointer_add (<array in caps>,x))
  141.  
  142.     <array in low> := required array name in lower case
  143.     <array in caps> := required array name in upper case
  144.     <data type> := char|int|long| or any other data type
  145.  
  146. It is also required to define the variable name in the variable list as
  147.  
  148.     void *<array in caps>
  149.  
  150. and then to declare the memory to be used by one of the following three 
  151. procedures given below.
  152.  
  153.     <array in caps>=char_array(<number of bytes>);
  154. or
  155.     <array in caps>=int_array(<number of words>);
  156. or
  157.     <array in caps>=long_array(<number of double words>);
  158.  
  159. --------------------------------------------------------------
  160.     As many large arrays may be declared as memory allows.
  161.     To access an array parenthesis are used instead of square brackets. 
  162.  
  163. (However, C++ routines could be used re-define the meaning of the square 
  164. brackets.)
  165.  
  166.     e.g.      printf ("%d\n", <array in low>(25));
  167.     would print out the 25th element of the array.
  168.  
  169. --------------------------------------------------------------
  170. Part 2 Using virtual arrays and hugh array
  171. ---------------------------------------------------------------
  172.  
  173. The virtual array procedures are an extension of the above routines.
  174.  
  175. The routines create a specified number of arrays in memory. If more arrays 
  176. are used than can fit into the memory allocated then the array that has 
  177. not been accessed for the longest is cached to disk or virtual disk.
  178.  
  179. All the virtual arrays must be of the same size. The array memory must be 
  180. initialised as follows.
  181.  
  182. initialise_virtual_arrays (<cache filename>,size of file buffer,
  183.               number of arrays to be stored in memory, size of each array,
  184.               maximum number of virtual arrays to be used)
  185.  
  186. This routine initialises a certain amount of memory depending on the size 
  187. of the array and the number of array buffers in memory. The actual arrays 
  188. do not take up disk space or memory until they are accessed.
  189.  
  190. To access an array the following procedure will return a pointer to the 
  191. array.
  192.  
  193.     void *img(<array number>)
  194.  
  195. (In the restricted version <array number> is between 0 and 15)
  196.  
  197. If the array is not in memory it will be created, if it does not exist, or 
  198. it will be loaded of disk. This pointer can be passed to a subroutine just 
  199. like a normal array.
  200.  
  201.     e.g.   
  202.          process (char picture[50][50])
  203.          {
  204.               .
  205.               .
  206.               Some code processing the array normally
  207.               .
  208.               .
  209.          }
  210.  
  211.          main ()
  212.          {
  213.               .
  214.               .
  215.               process (img(5));
  216.               .
  217.               .
  218.          }
  219.  
  220. ----------------
  221.     More than one array can be passed to a subroutine, but remember the 
  222. limit to the number of arrays, that you have specified, that can be held 
  223.  
  224. in memory at any one time.
  225.  
  226. Also remember that if an array has been cached then when it is restored it 
  227. may be restored to a different memory location.
  228.  
  229. ----------------------------------------------------
  230.  
  231.     Another useful procedure is 
  232.  
  233.     void *large_array (<array number>,<array index>)
  234.  
  235. This routine returns a pointer to the ith element of the <array number>.
  236.  
  237. A macro can then be defined to access a certain array where an array 
  238. number is assigned to an array name.
  239.  
  240.  
  241. #define <array name>(x) *((<data type<)large_array(<array number>,x))
  242.  
  243. -----------------------------------------------------------------------
  244. Hugh Arrays
  245.  
  246.     One hugh array can be created from a series of virtual images to 
  247. almost any size. An example is given in the file HUGHARR.C
  248.  
  249. ------------------------------------------------------------------------
  250. Please note that the swap file is not deleted when the program terminates, 
  251. so you will need to do that yourself.
  252.  
  253. ------------------------------------------------------------------------
  254. Part 3, Virtual arrays using extended memory
  255. ------------------------------------------------------------------------
  256.     The file XMSARRAY.ZIP contains files with the same name as the files 
  257. in the first two sections. By using this version the software operates 
  258. slightly fastest.
  259.     By using extended memory you have direct access to all your computers 
  260. memory quickly and easily from C.
  261.     To use this version of ARRAYS you need to have an extended memory
  262. manager device driver such as HIMEM.SYS installed otherwise it will not 
  263. work.
  264.     In this version all functions are the same except for the 
  265. initialisation of the array memory which no longer needs a file name. The
  266. initialisation function is shown below.
  267.  
  268. initialise_virtual_arrays (number of arrays to be stored in memory,
  269.               size of each array,
  270.               maximum number of virtual arrays to be used)
  271.  
  272. --------------------------------------------------------------------------
  273. In the future C++ routines will be devised to allow access to large arrays 
  274. using standard C array addressing which will allow for portability.
  275.  
  276.  
  277. Any suggestions for extending the functionality of the code will be 
  278. gratefully received.
  279.  
  280.