home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / sharew / exoten / rec / rec6.hlp < prev    next >
Encoding:
Text File  |  1990-10-26  |  11.0 KB  |  278 lines

  1. Chapter 6, Part I.  Operation of REC.
  2. Chapter 6, Part II.  User-supplied Extensions
  3. :        Ch. 6, Part I.  Operation of REC.
  4.  
  5.  
  6.     The execution of REC for running programs interactively is initiated 
  7. by a command line which simply contains the name of the desired REC compiler 
  8. (which may be REC80, REC80, REC80F, REC86F or REC87, depending on the 
  9. processor used and whether floating point arithmetic is desired).  If a 
  10. command line containing only, say, REC80F is given to CP/M, execution begins 
  11. with the following message displayed on the console (REC80 produces a similar 
  12. display):
  13.  
  14.             REC(8080)/ICUAP
  15.          Universidad Autonoma de Puebla
  16.                 [date]
  17.  
  18.          CPL ccccc
  19.          PDL ppppp
  20.          WS  wwww
  21.          Stk ssss
  22.  
  23.          REC80F>
  24.  
  25.  
  26.     ICUAP means "Institute of Sciences of the Autonomous University of 
  27. Puebla", [date] is the date of the REC version being executed, ccccc, ppppp, 
  28. wwww and ssss are decimal numbers indicating the sizes in bytes of the areas 
  29. available for compilation, pushdown list, workspace and machine stack, 
  30. respectively.  (When REC86 or REC86F are executed, additional data in 
  31. hexadecimal is displayed giving the segment base and length for each of the 
  32. four memory segments used by these compilers.)
  33.  
  34.     "REC80F>" in the above example is the prompt indicating that REC is 
  35. ready to read and execute a program.  The program may be entered in one or 
  36. more lines terminated by carriage returns (ASCII CR); REC starts execution of 
  37. the compiled program as soon as it recognizes the final right parenthesis or 
  38. brace.  When entering programs in this manner, care has to be taken to ensure 
  39. that all parentheses, braces, brackets and quotation marks (single and double 
  40. quotes) are correctly balanced; this is why the interactive execution of REC 
  41. is only recommended for testing simple programs or program fragments.
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.     As stated in Chapter 3, the execution of REC may also include 
  50. additional data on the command line, in which case REC takes the first 
  51. paramater on the command line tail to be the name of a file containing the 
  52. program whose compilation and execution is desired; the given name should 
  53. not contain an explicit extension, because the extension REC is always 
  54. assumed; the command line
  55.  
  56.         REC80 EXAMPLE
  57.  
  58. causes REC to compile and execute EXAMPLE.REC.  When REC is executed in this 
  59. manner, no display occurs on the console other than what the compiled REC 
  60. program itself produces; when this program's execution ends, REC returns 
  61. control of the computer to operating system.  If the file named on the 
  62. command line does not exist, REC returns to the operating system with no 
  63. further indication of the error.
  64.  
  65.     Under MS-DOS, the filename is searched in the current directory, and 
  66. if not found, in each directory listed in the PATH environment variable, 
  67. provided it has been given a value.  If not found anywhere, REC will display 
  68. the last pathname whose opening was attempted.
  69.  
  70. :        Ch. 6, Part II.  User-supplied Extensions.
  71.  
  72.     One letter of the ASCII alphabet, X, has been set aside to provide 
  73. access to user-defined operators (other than those defined as subroutines in 
  74. REC).  The compilation of X requires that it be followed by a character that 
  75. becomes a part of the calling sequence generated by the compiler (in the 
  76. style of @x); this character is analyzed by the run-time subroutine provided 
  77. by the user to identify the particular operator whose execution is desired.  
  78. Specifically, Xa is compiled as an operator, with the following calling 
  79. sequence:
  80.  
  81.         CALL    LIBO
  82.         DB    'a'
  83.  
  84.     The user-written extension must contain the entry point LIBO (which 
  85. in the case of REC80 and REC80F must appear in an ENTRY directive if an 
  86. assembler like Microsoft's M80 is used), and this program must be relinked 
  87. with the rest of the REC compiler (reassembled in case one uses ASM86 to 
  88. assemble REC86 or REC86F). Further on an example is given of the basic code 
  89. required for implementing operator X.
  90.  
  91.  
  92.  
  93.     The REC80 source program is divided into five modules:
  94.  
  95.     - REC80, which contains the compiling routines,
  96.     - PDL80, which contains the PDL predicates and operators,
  97.     - MKV80, which contains the workspace operators and predicates,
  98.     - LIB80, which contains the definition for predicate x, and
  99.     - FXT80, which contains tables, the CP/M interface and the initializing
  100.          routine; all other modules must precede this one in memory.
  101.  
  102.     Once M80 has assembled the above four modules, the executable module 
  103. REC80.COM is produced by the command line
  104.  
  105.     L80 MKV80,PDL80,REC80,LIB80,FXT80/E,REC80/N
  106.  
  107.     REC80F consists of seven modules, to wit,
  108.  
  109.     - FLT80F, which contains binary-ASCII and ASCII-binary 
  110.           conversion routines,
  111.     - ATH80F, which contains the arithmetic operators, and
  112.  
  113. REC80F, PDL80F, MKV80F, LIB80F and FXT80F, which contain functions similar
  114. to the analogously named REC80 modules.
  115.  
  116.     Analogously to REC80, the assembled modules may be linked with L80 to 
  117. create a REC80F executable module with the following command line, which 
  118. generates the file REC80F.COM:
  119.  
  120.     L80 MKV80F,PDL80F,ATH80F,FLT80F,REC80F,LIB80F,FXT80F/E,REC80F/N
  121.  
  122.     Notice that FXT80F must again be the very last module.
  123.  
  124.     For the 8086 versions, REC86 and REC86F, we have used CP/M-86's 
  125. assembler ASM86.  Even though the source programs for these compilers are 
  126. kept in 5 and 7 separate modules, respectively, ASM86 assembles all modules 
  127. together directed by an additional small module containing only INCLUDE 
  128. directives.  Thus, to assemble REC86, ASM86 is requested to assemble a file 
  129. REC86.A86, containing the following:
  130.  
  131.             CSEG
  132.             INCLUDE PDL86.A86
  133.             INCLUDE MKV86.A86
  134.             INCLUDE REC86A.A86
  135.             INCLUDE LIB86.A86
  136.             INCLUDE FXT86.A86
  137.             END
  138.  
  139.     The source module containing the compilation routines of REC is now 
  140. called REC86A; this is done so that ASM86 will produce, from the assembly of 
  141. the above small program, a file named REC86.H86, from which the executable 
  142. module REC86.CMD can be generated by GENCMD, a utility program provided by 
  143. CP/M-86.  The computer system on which REC86 was developed has 256kbytes of 
  144. memory, of which 192k are contiguous and start at address 00000H and the 
  145. remaining 64k start at address F0000H.  The command line we have used to 
  146. generate REC86.CMD is the following:
  147.  
  148. GENCMD REC86 CODE[M1000] DATA[M1000] EXTRA[A0F000,M0FFF] STACK[M0C00]
  149.  
  150. which allocates 64k for the code segment (which includes the compiler 
  151. itself), 64k for the data segment (including REC's PDL and the compilation, 
  152. variable and subroutine tables), 64k for the extra segment (containing the 
  153. workspace) and 48k for the 8086's machine stack.  The remaining 16k are used 
  154. by CP/M-86.
  155.  
  156.     To end our description of the standard REC compilers, we note that 
  157. the assembly of REC86F is similar to that of REC86, but in this case the 
  158. small module whose assembly is requested to ASM86 is called REC86F.A86 and 
  159. contains the following lines:
  160.  
  161.  
  162.             CSEG
  163.             INCLUDE PDL86F.A86
  164.             INCLUDE MKV86F.A86
  165.             INCLUDE ATH86F.A86
  166.             INCLUDE FLT86F.A86
  167.             INCLUDE REC86FA.A86
  168.             INCLUDE LIB86F.A86
  169.             INCLUDE FXT86F.A86
  170.             END
  171.  
  172.     The generation of the executable module REC86F.CMD is accomplished by 
  173. executing GENCMD with a command line entirely analogous to the one given for 
  174. REC86.
  175.  
  176.     Generation of the MS-DOS REC compilers requires only two simple 
  177. command lines:
  178.  
  179.             MASM REC8x
  180.             LINK REC8x
  181.  
  182. where REC8x is REC86, REC86F or REC87; prompts by MASM and LINK are answered 
  183. by pressing return.
  184.  
  185.     Suppose now that a user wants to add to REC80 the operators X0, X1, 
  186. X2, X3 and X4, and that any other predicate of the form Xa should effect an 
  187. immediate return.  The user would then provide a new module, say UOP80.MAC, 
  188. which would contain the following program (in which the explicit processes 
  189. represented by the five new operators are omitted): 
  190.  
  191.     ENTRY    LIBO    ;Declare LIBO to be an entry point
  192. ;
  193. LIBO:    POP    H    ;Pick up the return addr (calling seq. pointer)
  194.     MOV    A,M    ;Copy the character from the calling sequence
  195.     INX    H    ;Get the actual return address 
  196.     PUSH    H    ;push it back on the stack
  197.     CPI    '5'    ;Is the char. less than or equal to ASCII 5?
  198.     RNC        ;exit if not
  199.     SUI    '0'    ;Is the char. greater than or equal to 0?
  200.     RC        ;exit if not
  201. ;
  202. ;    Notice that register A now contains a value between 0 and 4
  203. ;
  204.     ADD    A    ;Multiply A by 2,
  205.     MOV    C,A    ;pass on to C,
  206.     MVI    B,0    ;extend to 2 bytes with a zero in B.
  207.  
  208.     LXI    H,TAB    ;The origin in the table of addresses
  209. ;            ;of subroutines X0 to X4
  210.     DAD    B    ;added to BC gives the address in the table
  211. ;            ;of the desired subroutine's entry address
  212.     MOV    E,M    ;which we copy to DE
  213.     INX    H
  214.     MOV    D,M
  215.     XCHG        ;pass on to HL
  216.     PCHL        ;and we jump to it.
  217. ;
  218. TAB:    DW    ZERO    ;ZERO is the address of the subroutine for X0
  219.     DW    ONE    ;ONE is X1's entry point
  220.     DW    TWO    ; and so forth
  221.     DW    THREE
  222.     DW    FOUR
  223. ;
  224. ZERO:    ...        ;Here we insert the instructions which carry
  225. ;            ;out the function associated with X0,
  226. ;
  227. ONE:    ...        ;In a similar manner for X1,
  228. ;
  229. TWO:    ...        ;X2,
  230.  
  231. ;
  232. THREE:    ...        ;X3
  233. ;
  234. FOUR:    ...        ;and X4.
  235. ;
  236.     END
  237.  
  238.     This module is assembled with M80 and linked to make an executable 
  239. module as follows:
  240.  
  241.     L80 UOP80,MKV80,PDL80,REC80,LIB80,FXT80/E,UREC80/N
  242.  
  243. where the new executable module's name is UREC80.COM.
  244.  
  245.  
  246.     To close the chapter, let us mention the predicate xa, which provides 
  247. a way to call predicates added to a REC program using operator C after its 
  248. execution has begun.  xa operates in a manner similar to @a in the sense that 
  249. it calls a predicate whose address is in a table indexed by the ASCII 
  250. character a; the difference is that @ always refers to a fixed table, whereas 
  251. the table referenced by x may be changed.
  252.  
  253.  
  254.     x@ is a predicate which takes, like @@, an argument from the PDL; if 
  255. it is a single byte, it is assumed to be an ASCII character to be used as an 
  256. index to the current table (for instance, '$'x@ has the same effect as x$).  
  257. However, if the PDL argument is a two-byte value, it must be the address of a 
  258. new table (whose indices are the ASCII characters exclamation point (!) 
  259. through tilde (~)), from which predicate x will take execution addresses in 
  260. subsequent uses, and until a new table is given by a further execution of x@ 
  261. with a two-byte argument.
  262.  
  263.     At the start of REC's execution, predicate x refers to the same table 
  264. as @, so that xa and @a produce the same result.  Once the table referenced 
  265. by x is changed, it is possible to reset it to the initial state by the use 
  266. of '!'$x@, since '!'$ places on the PDL the address of the portion of the 
  267. table of subroutines (called by @) starting at character "!".  Note that the 
  268. mechanism whereby braces ({ and }, see Chapter 1) deactivate external 
  269. definitions to activate internal ones only affects the table used by @ and 
  270. not that referenced by x, if the latter table is different from the former.
  271.  
  272.     This predicate has been used in the CONVERT compiler to effect 
  273. automatic inclusion of programs from a library when execution of a Convert 
  274. program is begun.
  275.  
  276. :[REC5-6.HLP]
  277. [(c) G. Cisneros, 1985, 1990]
  278.