Difference between revisions of "GenAsm (language)"

From Mill Computing Wiki
Jump to: navigation, search
m (fixed link)
 
(24 intermediate revisions by 2 users not shown)
Line 1:Line 1:
The genAsm assembly language is a low-level [https://en.wikipedia.org/wiki/Dataflow_programming| dataflow language] for writing programs to be executed on the Mill processors. The language is accepted by the [[genAsm (assembler)|genAsm assembler]], which create ELF files suitable as input to the [[prelinker]] or [[specializer]]. The assembler is intended for use when high-level language compilers are unable to provide a desired access to Mill hardware facilities.
+
The [[genAsm]] assembly language is a low-level [https://en.wikipedia.org/wiki/Dataflow_programming dataflow language] for writing programs to be executed on the Mill processors. The language is accepted by the [[genAsm (assembler)|genAsm assembler]], which create ELF files suitable as input to the [[prelinker]] or [[specializer]]. The assembler is intended for use when high-level language compilers are unable to provide a desired access to Mill hardware facilities.
  
Syntax in BNF:
+
Syntax in [https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form EBNF]:
  
BNF:
+
  '''"''' ... '''"'''  terminal keyword or symbol
Terminal keywords and symbols are italic; meta-symbols are bold.
+
  '''::='''      is defined as
 +
  '''|'''        alternatives
 +
  '''[''' ... ''']'''  option (zero or one times
 +
  '''{''' ... '''}'''  repetition (zero or more times)
 +
  ''','''        sequence (in order left-to-right)
 +
  ''';'''        end of definition
 +
 
  
     program ::=       moduleHead moduleBody-option
+
     program       ::= "module", moduleId, serial;
     moduleHead ::=     ''module'' identifier
+
     serial        ::= [expDef], {";", [expDef]};
     moduleBody ::=    functionDef-sequence
+
     expDef        ::= expression |
     functionDef ::=   ''func'' identifier parmsBinding resultSpec-option ''{'' functionBody ''}''
+
                        definition |
     parmsBinding ::=   ''('' parmList-option '')''
+
                        join, [expDef];
     parmList ::=       parm '''|''' parm '','' parmList
+
     definition    ::=  functionDef | labelDef;
     arg ::=           widthTag identifier
+
     functionDef   ::= ["inline"], "func", identifier, formals, [results], funcBody;
     widthTag ::=       ''b'' ''|'' ''h'' ''|'' ''w'' ''|'' ''d'' '''|''' ''q'' '''|''' ''bv'' '''|''' ''hv'' '''|''' ''wv'' '''|''' ''dv'' '''|''' ''qv''
+
     funcBody      ::= ":", expression | "outcall" | "forward";
     resultSpec ::=     ''->'' widthTag '''|''' -> ( resultList-option )
+
     formals        ::= "(", [formal, {",", formal}], ")";
     resultList ::=     widthTag '''|''' widthTag , resultList
+
     formal        ::= widthTag, identifier;
     functionBody ::=   expressionList-option
+
     widthTag       ::= "b" | "h" | "w" | "d" | "q" | "bv" | "hv" | "wv" | "dv" | "qv";
     expressionList ::= expression '''|''' expression '';'' expressionList
+
     results        ::= widthPack;
    expression ::=    secondary-option '''|'''
+
     widthPack      ::= "{", [widthTag, {",", widthTag}], "}";
                      expression invoke-option '''|'''
+
     labelDef      ::= "label", [widthPack], identifier, "forward";
                      expression binding '''|'''
+
     expression    ::= secondary |  
                      expression pick
+
                        expression, binding |
     secondary ::=     primary '''|''' secondary call
+
                        expression, gang, [secondary] |
     primary ::=       number widthSpec-option '''|''' argId '''|''' boundId '''|''' funcId '''|''' ''('' expression '')''
+
                        expression, ["inline"], funcId, [secondary] |
     widthSpec ::=     '':'' widthTag
+
                        expression, join |
     call ::=           ''('' argList-option '')''
+
                        expression, "?", expression, ":", expression;
     argList ::=       arg '''|''' arg '','' argList
+
     secondary     ::= primary |  
     binding ::=       ''-:'' identifier '''|''' ''-:'' bindings
+
                        secondary, "(", [expression, {",", expression}], ")" |
     bindings ::=      ''{'' idList ''}''
+
                        secondary, widthPack;
     pick ::=           ''?'' expression '':'' expression
+
     primary       ::= widthTag |
     idList ::=        identifier '''|''' identifier '','' idList
+
                        [widthTag, ":"], number |  
     invoke ::=         opCall '''|''' opId secondary-option
+
                        boundId |  
     opCall ::=        opId ''('' argList-option '')''
+
                        ebbId |
 +
                        ["inline"], funcId |  
 +
                        gang |
 +
                        "(", expression, ")" |
 +
                        "begin", serial, "end" |
 +
                        ifClause;
 +
     binding        ::= "-:", identifier |
 +
                        "-:", idenPack;
 +
     idenPack      ::= "{", identifier, {",", identifier}, "}";
 +
     gang          ::= opId, [".", opId];
 +
     opId          ::= identifier;
 +
    ebbId          ::=  identifier;
 +
     join          ::= ebbId, ":";
 +
    ifClause       ::=  "if", predPart, thenPart, {elifPart}, [elsePart], "fi";
 +
     predPart      ::= serial;
 +
    thenPart      ::=  "then", serial;
 +
     elifPart      ::= "elif", serial;
 +
    elsePart      ::=  "else", serial;
 +
    boundId        ::=  identifier;
 +
    funcId         ::=  identifier;
 +
    moduleId      ::=  identifier;
 +
    identifier    ::=  [qualification], name;
 +
     qualification  ::= [qualification], name, "::";
 +
    name          ::=  alpha, {alnum};
 +
    alnum          ::=  decDigit | alpha;
 +
    alpha          ::=  "_" | <"a"-"z"> | <"A"-"Z">;
 +
     decDigit      ::= <"0"-"9">;
 +
    number         ::=  decimal | hexadecimal | float;
 +
    decimal        ::=  decDigit, { decDigit };
 +
    hexadecimal    ::=  hexBase, hexDigit, { hexDigit };
 +
    hexBase        ::=  "0x" | "0X";
 +
    hexDigit      ::=  decDigit | <"a"-"f"> | <"A"-"F">;
 +
    float          ::=  decimal, ".", [decimal], [exponent] |
 +
                        decimal, [".", [decimal]], exponent;
 +
    exponent      ::=  "e", [sign], decimal |
 +
                        "E", [sign], decimal;
 +
    sign          ::=  "+" | "-";
 +
    comment        ::=  "//", {<char>}, <EOL> | "/*", {<char>}, "*/";

Latest revision as of 22:19, 12 January 2015

The genAsm assembly language is a low-level dataflow language for writing programs to be executed on the Mill processors. The language is accepted by the genAsm assembler, which create ELF files suitable as input to the prelinker or specializer. The assembler is intended for use when high-level language compilers are unable to provide a desired access to Mill hardware facilities.

Syntax in EBNF:

  " ... "   terminal keyword or symbol
  ::=       is defined as
  |         alternatives
  [ ... ]   option (zero or one times
  { ... }   repetition (zero or more times)
  ,         sequence (in order left-to-right)
  ;         end of definition
  
   program        ::=  "module", moduleId, serial;
   serial         ::=  [expDef], {";", [expDef]};
   expDef         ::=  expression |
                       definition |
                       join, [expDef];
   definition     ::=  functionDef | labelDef;
   functionDef    ::=  ["inline"], "func", identifier, formals, [results], funcBody;
   funcBody       ::=  ":", expression | "outcall" | "forward";
   formals        ::=  "(", [formal, {",", formal}], ")";
   formal         ::=  widthTag, identifier;
   widthTag       ::=  "b" | "h" | "w" | "d" | "q" | "bv" | "hv" | "wv" | "dv" | "qv";
   results        ::=  widthPack;
   widthPack      ::=  "{", [widthTag, {",", widthTag}], "}";
   labelDef       ::=  "label", [widthPack], identifier, "forward";
   expression     ::=  secondary | 
                       expression, binding | 
                       expression, gang, [secondary] |
                       expression, ["inline"], funcId, [secondary] |
                       expression, join |
                       expression, "?", expression, ":", expression;
   secondary      ::=  primary | 
                       secondary, "(", [expression, {",", expression}], ")" |
                       secondary, widthPack;
   primary        ::=  widthTag |
                       [widthTag, ":"], number  | 
                       boundId | 
                       ebbId |
                       ["inline"], funcId | 
                       gang |
                       "(", expression, ")" |
                       "begin", serial, "end" |
                       ifClause;
   binding        ::=  "-:", identifier | 
                       "-:", idenPack;
   idenPack       ::=  "{", identifier, {",", identifier}, "}";
   gang           ::=  opId, [".", opId];
   opId           ::=  identifier;
   ebbId          ::=  identifier;
   join           ::=  ebbId, ":";
   ifClause       ::=  "if", predPart, thenPart, {elifPart}, [elsePart], "fi";
   predPart       ::=  serial;
   thenPart       ::=  "then", serial;
   elifPart       ::=  "elif", serial;
   elsePart       ::=  "else", serial;
   boundId        ::=  identifier;
   funcId         ::=  identifier;
   moduleId       ::=  identifier;
   identifier     ::=  [qualification], name;
   qualification  ::=  [qualification], name, "::";
   name           ::=  alpha, {alnum};
   alnum          ::=  decDigit | alpha;
   alpha          ::=  "_" | <"a"-"z"> | <"A"-"Z">;
   decDigit       ::=  <"0"-"9">;
   number         ::=  decimal | hexadecimal | float;
   decimal        ::=  decDigit, { decDigit };
   hexadecimal    ::=  hexBase, hexDigit, { hexDigit };
   hexBase        ::=  "0x" | "0X";
   hexDigit       ::=  decDigit | <"a"-"f"> | <"A"-"F">;
   float          ::=  decimal, ".", [decimal], [exponent] |
                       decimal, [".", [decimal]], exponent;
   exponent       ::=  "e", [sign], decimal |
                       "E", [sign], decimal;
   sign           ::=  "+" | "-";
   comment        ::=  "//", {<char>}, <EOL> | "/*", {<char>}, "*/";