home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MODEM / UWPC201.ZIP / TERMCC.DOC < prev    next >
Encoding:
Text File  |  1991-11-15  |  18.2 KB  |  420 lines

  1.                Termcap Compiler Version 1.01
  2.  
  3.                  Copyright (C) 1991 Rhys Weatherley
  4.  
  5. 1. INTRODUCTION
  6.  
  7. The Termcap Compiler is a tool for creating new terminal emulations for use
  8. with UW/PC (versions 2.00 and higher).  It takes source code in the form of an
  9. abstract assembly code and compiles them into binary terminal descriptions that
  10. UW/PC can use to provide new types of terminal emulations.  The standard UW/PC
  11. terminal types are included as examples of the assembly code versions of the
  12. terminal descriptions in the files VT52.CAP, ADM31.CAP and ANSI.CAP in the
  13. source code archive UW-SRC.ZIP.
  14.  
  15. 2. USING THE TERMCAP COMPILER.
  16.  
  17. The Termcap Compiler "TERMCC" accepts assembly code from the filename supplied
  18. as an argument and writes the resultant compiled terminal description to the
  19. supplied output file or a file with the same path and name as the input file,
  20. but with a ".TRM" extension.  The full command syntax is:
  21.  
  22.     TERMCC infile[.CAP] [outfile[.TRM]]
  23.  
  24. 3. USING NEW TERMINAL DESCRIPTIONS WITH UW/PC.
  25.  
  26. This section explains how you can add terminal descriptions you have written
  27. and compiled to UW/PC so that it will use them during communications.  This
  28. is also explained in "UW.DOC", but is repeated here for convenience.
  29.  
  30. In the configuration file "UW.CFG" for UW/PC the following configuration
  31. options can be specified:
  32.  
  33.     emul (default adm31)
  34.  
  35.         The default terminal emulation type to use for windows.
  36.         When a new window is created, it will use this emulation
  37.         type.  This can be one of adm31, vt52, or ANSI or a string
  38.         (e.g. "vt102"), signifying a currently loaded terminal
  39.         description that will be searched for to become the
  40.         default emulation.  The double quotes are optional.
  41.         When the terminal description is searched for, case is
  42.         ignored during compares.
  43.  
  44.     emul0 (defaults to whatever emul is set to)
  45.  
  46.         Set the terminal emulation type for protocol 0.  This is
  47.         to rectify some problems with UNIX termcap entries that
  48.         are missing the entry for ADM31 terminals, as discussed 
  49.         above under "USING UW/PC".  It can be one of adm31, vt52
  50.         or ansi or a string specifying a terminal type loaded
  51.         with the "terminal" configuration option.
  52.  
  53.     terminal (no default)
  54.  
  55.         This can appear up to five times in the configuration file
  56.         and each occurrence will load a terminal description into
  57.         memory.  It's string value specifies a filename for a
  58.         compiled terminal description.  The full pathname should be
  59.         supplied.  For example, the following line could be added to
  60.         the configuration file to add a "VT102" terminal emulation:
  61.  
  62.             terminal="c:\uw\vt102.trm"
  63.  
  64.         The standard VT52, ADM31 and ANSI terminal types can be
  65.         replaced with new terminal descriptions by loading new
  66.         files that have the VT52, ADM31 or ANSI terminal type
  67.         specified.
  68.  
  69. 4. THE ABSTRACT MACHINE.
  70.  
  71. UW/PC uses a small interpretive abstract machine to decode compiled terminal
  72. descriptions on the fly while performing communications.  Its overhead is
  73. small enough not to have a significant impact on the performance of UW/PC.
  74. This abstract machine has a number of registers that can be accessed from
  75. the assembly code described in the next section.
  76.  
  77.     accumulator    - This is the primary control register.  It holds
  78.               16 bit signed values.
  79.     x register    - This is an auxillary register, primarily used for
  80.               cursor positioning during terminal emulation.  It
  81.               holds 16 bit signed values.
  82.     y register    - This is an auxillary register, primarily used for
  83.               cursor positioning during terminal emulation.  It
  84.               holds 16 bit signed values.
  85.     comparator    - After a comparison instruction, this register will
  86.               hold a value that is inspected during the conditional
  87.               jump instructions.  Its (16 bit) value cannot be
  88.               directly accessed.
  89.     flags        - This is a 16 bit quantity that allows you to record
  90.               up to 16 single bit flags that may be useful for
  91.               recording such information as whether the terminal's
  92.               insertion mode is on or off, etc.
  93.     saved x reg    - An auxillary register that can be used to save the
  94.               terminal's current X cursor co-ordinate.  It's value
  95.               cannot be directly accessed, except through the
  96.               "savexy", "restxy" and "getxy" instructions.
  97.     saved y reg    - An auxillary register that can be used to save the
  98.               terminal's current Y cursor co-ordinate.  It's value
  99.               cannot be directly accessed, except through the
  100.               "savexy", "restxy" and "getxy" instructions.
  101.     saved attribute    - An auxillary register that can be used to save the
  102.               terminal's current printing attribute.  It's value
  103.               cannot be directly accessed, except through the
  104.               "saveattr" and "restattr" instructions.
  105.     argument array    - An array of eight 16-bit quantities that can be used
  106.               to store arguments to escape sequences for emulations
  107.               such as ANSI and VT102 which have variable numbers of
  108.               arguments for their escape sequences.
  109.     number of args    - A 16-bit quantity that normally records how many
  110.               arguments are in the argument array.  It can also
  111.               be used as a loop counter.
  112.  
  113. 5. ASSEMBLY INSTRUCTIONS.
  114.  
  115. This section describes the format of the assembly source file, and the various
  116. instructions that can be used to create terminal descriptions.
  117.  
  118. The source file can contain comments that begin with "//" and continue to the
  119. end of the line (like in C++), and it must begin with a "name" instruction,
  120. although this is not checked by the compiler.  There is no fixed format for
  121. the instructions except that labels cannot occur between an instruction's
  122. name and its arguments.  Other than that, an instruction can appear in any
  123. way with any amount of white space and comments surrounding its name and
  124. arguments, and any number of instructions and labels can appear on the one
  125. line or wrapped across lines.  Despite this, it is better to only place one
  126. instruction on each line with an optional label preceding it, as shown in the
  127. example terminal descriptions.
  128.  
  129. Labels consist of an alphanumeric identifier (that must not be an instruction
  130. name) and a colon.  The two labels "start" and "keys" must be present in the
  131. source file.  "start" indicates where the decoding for output to the terminal
  132. screen begins, and "keys" indicates where the decoding of special keycodes
  133. (for example terminal function keys) begins.  Without these labels, UW/PC
  134. cannot process the terminal description properly.
  135.  
  136. There is one special escape sequence that EVERY terminal type MUST support:
  137. "ESC |".  This will be used by UW/PC together with some of the upcoming
  138. enhancements to UW/PC.  The handling for this escape sequence is to use
  139. "getch" to retrieve the next character after the '|' and then to execute the
  140. "client" instruction.  If a terminal description does not handle this escape
  141. sequence in this way, then the special clients cannot be activated in
  142. windows of that terminal type.
  143.  
  144.     add    - Adds the instruction's argument to the accumulator.
  145.           The argument can be numeric, "width" or "height".
  146.  
  147.     bell    - Ring the terminal bell.
  148.  
  149.     bs    - Move the cursor back one character.  The cursor will
  150.           not wrap around to the previous line if it is at the
  151.           start of the current line.
  152.  
  153.     bswrap    - Move the cursor back one character and wrap around to
  154.           the end of the previous line if necessary.  If the cursor
  155.           is in the top-left screen position, it won't be moved.
  156.  
  157.     clear    - Clear the entire screen to the current scrolling attribute.
  158.           The cursor is not moved from its current position.
  159.  
  160.     client    - This should be executed for the escape sequence ESC '|'.
  161.           UW/PC uses this for some of its specialised clients such
  162.           as the upcoming mail tool uwmail.
  163.  
  164.     clreol    - Clear to the end of the current line in the current
  165.           scrolling attribute.
  166.  
  167.     clreos    - Clear to the end of the screen from the current cursor
  168.           position in the current scrolling attribute.
  169.  
  170.     clrsol    - Clear to the start of the current line in the current
  171.           scrolling attribute.  The current cursor position is
  172.           not cleared.
  173.  
  174.     clrsos    - Clear to the start of the screen from the current
  175.           cursor position in the current scrolling attribute.
  176.           The current cursor position is not cleared.
  177.  
  178.     cmp    - Compares the instruction's argument to the accumulator.
  179.           The argument can be numeric, "width" or "height".  The
  180.           comparator will be set to reflect the result of the
  181.           comparison.
  182.  
  183.     cr    - Move the cursor to the start of the current line.
  184.  
  185.     dec    - Decrement the number of arguments and compare it with zero,
  186.           putting the result of the comparison into the comparator.
  187.  
  188.     delchar    - Delete the character at the current screen position,
  189.           moving all following characters left one place and
  190.           clearing the last position on the line in the current
  191.           scrolling attribute.
  192.  
  193.     delline    - Delete the current line and scroll the screen up.
  194.  
  195.     endkeys    - Marks the end of the key definition table.
  196.  
  197.     escape    - Unused at present - takes a numeric argument and specifies
  198.           and index to use in an "escape" table which isn't currently
  199.           implemented.  This is a convenient way to extend the
  200.           language without changing the TERMCC program - only the
  201.           main UW/PC program needs to be modified to recognise the
  202.           escape sequences.  It is suggested that you do not use
  203.           this because it may change in different versions of the
  204.           program, but is handy for "quick hacks".
  205.  
  206.     geta    - Gets an argument from the argument array.  This instruction's
  207.           first argument (1..8) specifies the argument to get and its
  208.           second argument specifies an 8-bit default value to use if
  209.           the argument in the argument array is not set.
  210.  
  211.     getarg    - Gets an argument from the remote host.  It is assumed to
  212.           be the ASCII representation of a number.  The number will
  213.           be placed into the next argument position and the
  214.           accumulator will return the character that follows the
  215.           number in the stream from the remote host.
  216.  
  217.     getch    - This instruction will wait until the next character is
  218.           received from the remote host, which it will place into
  219.           the accumulator, and then it will continue execution.
  220.  
  221.     getx    - Get the value of the X register and place it into the
  222.           accumulator.
  223.  
  224.     getxy    - Get the current cursor position and place it into the
  225.           X and Y registers.  This is mainly used to get a cursor
  226.           position prior to moving it about the screen.
  227.  
  228.     gety    - Get the value of the Y register and place it into the
  229.           accumulator.
  230.  
  231.         insblank - Insert a blank character without moving the cursor.
  232.  
  233.     inschar    - Insert the accumulator at the current screen position,
  234.           moving all present characters one position to the right.
  235.           If an insertion is performed at the right-most position,
  236.           then this instruction has the same effect as "send".
  237.  
  238.     insline    - Insert a new blank line before the current screen line.
  239.  
  240.     ja    - Jump to the label given as an argument if the result of
  241.           the last comparison using "cmp" was that the accumulator
  242.           was above (greater than) the comparison value.
  243.  
  244.     jae    - Jump to the label given as an argument if the result of
  245.           the last comparison using "cmp" was that the accumulator
  246.           was greater than or equal to the comparison value.
  247.  
  248.     jb    - Jump to the label given as an argument if the result of
  249.           the last comparison using "cmp" was that the accumulator
  250.           was below (less than) the comparison value.
  251.  
  252.     jbe    - Jump to the label given as an argument if the result of
  253.           the last comparison using "cmp" was that the accumulator
  254.           was less than or equal to the comparison value.
  255.  
  256.     je    - Jump to the label given as an argument if the result of
  257.           the last comparison using "cmp" was that the accumulator
  258.           was equal to the comparison value.
  259.  
  260.     jne    - Jump to the label given as an argument if the result of
  261.           the last comparison using "cmp" was that the accumulator
  262.           was not equal to the comparison value.
  263.  
  264.     jmp    - Jump unconditionally to the label given as an argument.
  265.  
  266.     jsr    - Jump to a subroutine at the label given as an argument.
  267.           Subroutines can only be nested up to 10 levels deep.  If
  268.           you go any deeper, it is not checked (for speed) and
  269.           strange things may occur.
  270.  
  271.     key    - Takes two arguments separated by a comma.  The first is
  272.           an IBM keyboard scan code indicating a key to be mapped
  273.           to the second argument which is a string of characters to
  274.           be sent to the remote host when that key is pressed.  Use
  275.           this to define the characters to send for arrow and function
  276.           keys in a terminal emulation.  It is assumed that the
  277.           label "keys" is followed by zero or more "key" instructions
  278.           and terminated with an "endkeys" instruction so that UW/PC
  279.           can find the key definitions.  No other instructions must
  280.           appear in the "keys" section otherwise strange things may
  281.           happen.
  282.  
  283.     load    - Loads the instruction's argument into the accumulator.
  284.           The argument can be numeric, "width" or "height".
  285.  
  286.     lf    - Move the cursor down one line on the screen, staying
  287.           in the same column.  At the bottom of the screen, the
  288.           screen is scrolled up one line.
  289.  
  290.     move    - Move the cursor to the position denoted by the X and Y
  291.           registers.  The screen origin is at (0,0).  If the
  292.           position is off-screen, the cursor is not moved.
  293.  
  294.     name    - Takes a string argument that specifies the name of the
  295.           terminal emulation.  This must be the first instruction
  296.           in the terminal description, but this is not checked.
  297.  
  298.     remote    - Send the value in the accumulator to the remote host.
  299.  
  300.     restattr - Restore the current printing attribute that was saved
  301.           by using "saveattr".
  302.  
  303.     resarr    - Resets the argument array.  All arguments will be marked
  304.           as "default value", the argument counter will be set
  305.           to zero, and the "shift" instruction value will be set
  306.           to zero.
  307.  
  308.     reset    - Takes a numeric argument which is a number between 0 and
  309.           15 that indicates a bit in the flags register to be reset.
  310.  
  311.     restxy    - Restore the current cursor position from the saved X and
  312.           Y registers.  The values may be saved by the "savexy"
  313.           instruction.
  314.  
  315.     ret    - Return from the current subroutine.  If you go up past
  316.           the first return address on the return stack then it
  317.           is not checked (for speed) and strange things may occur.
  318.  
  319.     saveattr - Save the current printing attribute so it can be later
  320.           restored using "restattr".
  321.  
  322.     savexy    - Save the current cursor position in the saved X and Y
  323.           registers.  The values may be restored by the "restxy"
  324.           instruction.
  325.  
  326.     scrldn    - Scroll the entire screen down one line, leaving the cursor
  327.           at its current position and filling the top line in
  328.           the scrolling attribute.
  329.  
  330.     scrlup    - Scroll the entire screen up one line, leaving the cursor
  331.           at its current position and filling the bottom line in
  332.           the scrolling attribute.
  333.  
  334.     send    - Send the accumulator to the screen.  When the cursor
  335.           reaches the right-hand side of the screen, it will
  336.           automatically wrap to the start of the next line, and
  337.           will scroll the screen as necessary.
  338.  
  339.     send52    - Send the accumulator to the screen.  When the cursor
  340.           reaches the right-hand side of the screen, it will
  341.           stay at that position until the next invocation of
  342.           "send" or "send52".  It got this name because this is
  343.           what the VT52 terminal type does.
  344.  
  345.     set    - Takes a numeric argument which is a number between 0 and
  346.           15 that indicates a bit in the flags register to be set.
  347.  
  348.     setattr    - Set the current printing attribute.  If a numeric
  349.           argument is supplied then the attribute is set from
  350.           the global attribute table (see below).  Otherwise,
  351.           the current accumulator value is used as the attribute.
  352.           The indexes into the global attribute table are:
  353.  
  354.               0 - Normal printing attribute.
  355.             1 - Inverse printing attribute.
  356.             2 - Highlighting attribute - usually "bold".
  357.             3 - Normal attribute on the status line.
  358.             4 - Highlighting attribute for the status line.
  359.  
  360.     setscrl    - Set the current scrolling attribute.  If a numeric
  361.           argument is supplied then the attribute is set from
  362.           the global attribute table (see above).  Otherwise,
  363.           the current accumulator value is used as the attribute.
  364.  
  365.     setc    - Set the number of arguments directly from the accumulator.
  366.           This is useful to use the number of arguments register as
  367.           a counter in loops, decrementing it with "dec" each time
  368.           through a loop.  The argument array is not modified, and
  369.           "geta" and "shift" can still be used to step through the
  370.           array to get the arguments.
  371.  
  372.     setx    - Places the value of the accumulator in the X register.
  373.  
  374.     sety    - Places the value of the accumulator in the Y register.
  375.  
  376.     shift    - Shift the arguments back one.  Using a "geta" instruction
  377.           after this instruction will get the "n + 1"th argument.
  378.           e.g. in "geta 1,1 shift geta 1,1", the second "geta"
  379.           instruction will get the argument following the first.
  380.           The "resarr" instruction will move everything back to the
  381.           start of the argument array.
  382.  
  383.     sub    - Subtracts the instruction's argument from the accumulator.
  384.           The argument can be numeric, "width" or "height".
  385.  
  386.     switch    - Extended comparison instruction that ends with "endsw".
  387.           Between "switch" and "endsw" are placed value and
  388.           jump label pairs.  For example:
  389.  
  390.             switch
  391.               0x00,start
  392.               '\r',crproc
  393.               '\n',lfproc
  394.               '\b',bsproc
  395.               '\t',tabproc
  396.               0x07,bellproc
  397.               0x1B,escproc
  398.             endsw
  399.  
  400.           The "switch" instruction will try to match each value
  401.           against the accumulator in turn, and will jump to the
  402.           associated label of the first matching value.  If no
  403.           values match, then execution will continue after the
  404.           "endsw" instruction.
  405.  
  406.     tab    - Move the cursor to the next tabstop.  Tabstops are
  407.           placed every 8 characters, and the cursor will wrap to
  408.           the start of the next line and will scroll the screen
  409.           as necessary.
  410.  
  411.     test    - Takes a numeric argument which is a number between 0 and
  412.           15 that indicates a bit in the flags register to be tested.
  413.           The comparator is set to a non-zero value if the flag bit
  414.           is set, and zero if it is reset.  The comparator can then
  415.           be tested with "je" (for reset) and "jne" (for set).
  416.  
  417. You should look at the standard VT52, ADM31 and ANSI terminal types that come
  418. with the UW/PC source code for more information on how to write terminal
  419. descriptions.  Please report any bugs or enhancements to the author.
  420.