home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / CPMUG / CPMUG036.ARK / ML80.REF < prev    next >
Text File  |  1984-04-29  |  9KB  |  225 lines

  1. This is documentation of ML80 extracted from L. R. B. Pedroso's thesis,
  2. "ML80:  A structured machine-oriented microcomputer programming language."
  3. The thesis is available from the National Technical Information Service as
  4. order number AD/A-020 055 for $7.75 (on the last price list I saw).  It
  5. includes complete PL/M source code listings as well as the formal grammars
  6. and fairly complete discussion and examples.  The source code is available
  7. from the Intel Users' Library for $70.  What follows is on the order
  8. of a quick reference guide to ML80.
  9.  
  10.     ML80 is actually two language processors, M80 and L80.  M80 is a
  11. general macro processor which can be used independently of L80 for any
  12. macro processing.  L80 is a structured assembly language for the 8080
  13. microprocessor, and almost all of the operations allowed directly
  14. reflect one or two 8080 instructions.
  15.  
  16.  
  17.             SUMMARY OF M80 SYNTAX
  18.  
  19. [INT id1 id2 ...]        Declare integer macros, initial value zero
  20.  
  21. [id := expr]            Assign new value to integer macro
  22.  
  23. [DEC expr]            Substitute decimal value of expr in text
  24. [OCT expr]            Substitute octal value
  25. [HEX expr]            Substitute hexidecimal value
  26. [CHAR expr]            Substitute ASCII character, 0=NUL,
  27.                 32 = SPACE, 65= A, etc.  Note that this is
  28.                 the only way to get [, ], and ' in the result.
  29. [id]                Substitute the (decimal) value of id
  30.                 Note on all of the above that no characters
  31.                 bracket the final substitution.  Thus the
  32.                 string 'XX[DEC 23H]YY' becomes 'XX35YY'
  33.  
  34. [MACRO mname fp1 fp2 ... fpn 'string']    Define new macro with name mname and
  35.                 formal parameters fp1 ... fpn and body string
  36.  
  37. [mname 'str1' 'str2' ... 'strn']    Replace by result of substituting str1
  38.                 ... strn for the formal parameters of mname in
  39.                 the macro body.  The quotes ARE needed.
  40.  
  41. [IF expr THEN 'string']        Replace by string if the least significant
  42.                 bit of expr (in binary) is 1.
  43. [IF expr THEN 'str1' ELSE 'str2']    Replace by one of the strings
  44.                 depending on expr.
  45.  
  46. Of the above, INT, assignment, MACRO and a false THEN-only IF are replaced
  47. by the empty string.
  48. Comments may be embedded in macro bodies by /* comment */ device.
  49. Expressions are composed of (in order of increasing priority):
  50.  
  51. \   for OR    \\   for XOR
  52. &   for AND
  53. !   for NOT
  54. =   <   >   <=   >=   <>   for comparisons
  55. +   -
  56. *   /           % for MOD
  57. integer-id   number   -number    (expr)    (id := expr)
  58.  
  59. The value of expressions are limited to integers +/- 32767
  60. Numbers may be written in hex, decimal, octal or binary by using the suffix
  61. H, D, Q and B respectively.  Hex numbers must start with a decimal digit.
  62. Identifiers within an expression are NOT bracketed.
  63.  
  64. In strings, use two consecutive quotes '' to represent a single quote.
  65. Macro calls are recognized even within strings.
  66.  
  67. M81 processor errors:
  68. M81 writes all error messages embedded in the output text being processed.
  69. These messages may be found by searching for
  70. *** LINE nnnn: ERROR nn
  71. in column 1.  From ED, use     F^L*** LINE^Z0TT    to find and
  72. print the next message.
  73.  
  74. Error    Meaning
  75.  1    Unexpected EOF.  Probably mismatched ' or [.
  76.  2    Mispelled number
  77.  3    Number too large, -32768 to 32767 only
  78.  7    Syntax error
  79. 11    Undefined macro, probably misspelled or wrong number of parms
  80. 12    Numeric macro has parms
  81. 13    More actual parms than formal parms
  82. 14    Nonnumeric assignment
  83. 15    Nonnumeric expression
  84.  
  85.     The following errors abort processing
  86. F1    Too many macros
  87. F2    Too much nesting of macro calls
  88. F3    Strings too long
  89. F5    M81 error
  90. F7    unrecoverable syntax error
  91.  
  92. L80.
  93. L80 is implemented as three modules, L81 -- the parser, L82 -- code generator,
  94. and L83 -- linker.  Note that if you write a program without macros
  95. you don't need M81.
  96. L81 and L82 each process a single program file, but L83 can combine several
  97. if it is given a file which declares  external procedures.
  98. For each external procedure, it will also load the file of the same name.
  99.  
  100. Capsule summary of L80 syntax
  101.  
  102. Program ::=     stmt; stmt; ... EOF
  103. Stmt    ::=    ident:stmt        defines ordinary label here
  104.         number:stmt        puts stmt at absolute location
  105.         IF cond THEN stmt {ELSE stmt}        note else optional
  106.         DECLARE     id       {(length)}BYTE    variables
  107.             (id1, id2,..) LABEL        for forward GOTOs
  108.                       EXTERNAL        external proc
  109.                       COMMON        external data
  110.                       DATA(const, const, ...)  a constant variable
  111.             BYTE may be followed by
  112.                 INITIAL(const, const, ...) initialize ONCE
  113.         DO; stmts; END ident        grouping for IF etc.
  114.         DO assign {BY assign} WHILE cond; stmts; END
  115.             Note that you must be sure to set flags for while
  116.         DO CASE HL; c0stmt; c1stmt; ...; END    do one alternative
  117.             Note that this changes HL, uses array of labels(fast)
  118.         ident:PROCEDURE{(id, id,...)}; stmts; END
  119.         RETURN
  120.         IF simple-cond RETURN        Note no THEN, generates RC etc
  121.         CALL ident{(const, const,...)}    Note parms are constants
  122.         CALL number            No parms, CALL 0 gives RST 0, etc
  123.         IF simple-cond CALL id/number    No parms, uses CC, etc
  124.         GOTO M(HL)
  125.         GOTO ident/number
  126.         IF simple-cond GOTO id/number    Uses JZ etc
  127.         REPEAT; stmts...; UNTIL cond    Always done at least once.
  128.         HALT
  129.         NOP
  130.         DISABLE                Interrupts of course
  131.         ENABLE                Ditto
  132.         A::expr            CMP or CPI
  133.         HL==reg-exp        XCHG or XTHL
  134.         var=reg-exp        Watch possible registers
  135.         reg=expr
  136.  
  137. The following are builtin, reserved variables:
  138. M(BC)   M(HL)  M(DE)   M(const)   IN(number)   OUT(number)
  139. A, B, C, D, E, H, L, BC, DE, HL, PSW, SP, STACK (meaning top), CY.
  140. All assignments and expressions must have an 8080 op code (except
  141. that HL=BC (etc) work).  Thus BC=BC+5 is illegal.
  142.  
  143. simple-cond ::= {(stmts)} flag        Optional stmts can be used to set
  144.                 PSW for flag test
  145. flag ::=  ZERO |  ! ZERO  |  CY  |  ! CY  | PY EVEN  |  PY ODD  | PLUS | MINUS
  146. COND ::=  simple-cond  & simple-cond & ...        Several anded tests
  147.       simple-cond \ simple-cond \ ...    or several ored tests.
  148.             And and or can't be mixed in one cond.
  149. CONSTANT ::=  .'string'  |  'string'  |  number  |  -number
  150.           .ident  |  .ident(number)
  151. . denotes address of, gives a two byte constant.
  152. Expressions are evaluated left to right, except a parenthesized register
  153. expression within an axpression is done just before needed.  E.g.
  154. A=M(7)+(B=8),-2; compiles as LDA 7!  MVI B,8!  ADD B!  SUI 2
  155. Unary operations always follow an assignment =, but nested
  156. expressions to the right are still possible.  All operators are equal
  157. priority and ldft to right.  Operators are:
  158. +    add        -    sub
  159. ++    adc        --    sbb
  160. &    and        \    or        \\    xor
  161. <    ral        <<    rlc
  162. >    rar        >>    rrc
  163. !    cma/cmc        #    daa
  164.  
  165. !, #, >, >>, <, << are unary operations.
  166. Following the first operator in an expression, all subsequent operators are
  167. delimited with a comma. +/- 1 is recognized as incr/decr-ement.
  168. Beacause of 8080 instruction limitations, most occurances of non-register
  169. variables are limited to assignment to and from A and HL.  Generally,
  170. most places a variable or register may occur on the right side of an
  171. operation, a parenthsized assignment to that variable is allowed (as the
  172. (B=8) in the example above.
  173.  
  174.             ERRORS
  175. L81 prints all its error messages to the console in plain text (giving
  176. line number and error message).  If you use no CR/LF sequences inside
  177. macros, these line numbers will be the same as the M80 macro source.
  178. CR/LF in a macro body will put extra lines in while CR/LF inside macro
  179. calls will remove a line.
  180.  
  181. L82 errors.    Also given in terms of line number.
  182. Error    Meaning
  183. 00    INITIAL data too long, truncated on left.
  184. 01    Identifier redeclared in same block.
  185. 02    Identifier redeclared (ignored).
  186. 03    Invalid procedure name.
  187. 04    Reference to undeclared identifier.  Usually either mispelled,
  188.     lost in some earlier error or forgot to declare label for forward
  189.     branch.
  190. 05    Wrong number of parms in procedure call.
  191. 06    Invalid call (not a procedure or undefined)
  192. 07    Not a machine operation (no 8080 instruction does this)
  193.     This often follows 04 as 04 is fixed up by substituting M(0).
  194. 08    Feature not implemented.    (E.g. CASE DE in DO)
  195. 0A    Invalid constant
  196. 0B    Invalid GOTO destination, not a label or number
  197. 0E    Reference to undefined address
  198.         TERMINAL ERRORS
  199. F1    Too many nested statements
  200. F2    Too many symbols in one block
  201. F3    Too many nested blocks
  202. F4    Too many unresolved cases
  203. F5    Parser actions file (.80P) contains error
  204. F6    Symbol list overflow, too many symbols and strings
  205.  
  206.  
  207. L83 errors  (all terminal)
  208. 1    Too many modules (file groups)
  209. 2    Memory overflow (segment too big)
  210. 3    Bad relocation record (in .80R)
  211.  
  212.  
  213. Files used in ML80
  214. x.M80    macro source input
  215. x.L80    macro expansion output, L81 input source
  216. x.80S    Symbol table, out from L81, into L82 and L83
  217. x.80P    Parser actions, from L81 to L82
  218. x.80C    L82 output of code and constants, to L83
  219. x.80D    L82 output of initializing data for variables, to L83
  220. x.80R    L82 output of relocation information, to L83
  221. x.COM    CP/M command file after linking
  222.  
  223. L83 doesn't do it, but all material from x.80C could by put in PROM,
  224. with material from 80D loaded to initialize the program (after relocation).
  225.