home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol166 / reccom.rec < prev    next >
Encoding:
Text File  |  1984-04-29  |  6.8 KB  |  139 lines

  1.  
  2. [RECCOM.REC]
  3. [CNVRT compiler for REC]
  4. [a version which compiles "assembler" code]
  5. [Harold V. McIntosh, 28 April 1982]
  6. [Harold V. McIntosh, 2 June 1983]
  7. [Harold V. McIntosh, 28 December 1983]
  8.  
  9. [[]]
  10.  
  11. {
  12.                    {
  13.     [find/make FCB]        (Jj'TTY:'EQZD;(':'UQD':'ED\64-%;0%;)
  14.                  ('.'U<(8a;@b;)Q|D>;Z'.DAT'IJj:)
  15.                   '.'FJDZ(3a;@b;)Q|JZDI
  16.                  32(dpGm$r0=npGpGd0&$Sm@znpGQ&$rrS0;
  17.                  r12wQmwnEn;n:)D;) f
  18.     [blank fill by count]    (Zz(d' 'I:;)JZ;) b
  19.     [zero fill]            (cmpw0%(f:;)w;) 0
  20.     [zero FCB & buffer]        ($m33@0130@0nn&0||pLnS;) z
  21.     [set default input file]    (0,30$S'5C'H12wA' 'Ew4@0n0|0|pL31$S
  22.                  'TTY:'31$rrS; B9aQD(3a'   'E
  23.                  'DAT';Q;)|mw31@zn31$rrS31@r;) i
  24.     [open for read]        (@hr15K(255='NO FILE'I;L;)L;) r
  25.     [open for write]        (@hpGpG4+1&SrpG19k22k^^r128&S;) w
  26.     [set DMA address]        ($rpG^^r^^26k;) h
  27.     [open]            (m@f0=n@@;nLL;) O
  28.     [read]            (''(AL@f(0=pG@r;'TTY:'(='T');))
  29.                  ('T'='';L31pG$rr12w'TTY:'Ew;w)
  30.                  L@&'> 'TL(@#I;:);
  31.                  $r(pG^^rpGmr(0=(npGpGm128&S^^26kpGr
  32.                  20K0=L;LL1npGpGm129+26%&SS;)npGmr;;)
  33.                  pG130&-n+&dm(u13%=;10%(=)pGI(26%=;
  34.                  L);ndm:)L^^rn&S;LpG^^r0&S:);) R
  35.     [write]            (Jj'='U<(A@f'TTY:'(=)(0=pG@w;;))>'='ED
  36.                  ZqtD; >'='EDZ<@g;) W
  37.     [write to disk]        ($r(pG^^rpGpGmrpGm- 130+n&maQD>Z<nSn^^
  38.                  26kpGr21kpG^^r128&S:JZQD>nSnSL;);) g
  39.     [close all files]        (31pGm($r0=;pG4+r(0=L;LJj26%I<npGm@gpG
  40.                  ^^rpGr127(N^^26kpGr21k;L;)r16k;)ndpGm:)
  41.                  nL;;) c
  42.     [PVR]            (pG@&#'= '|TL$r(0='undef';yG;)TL;) _
  43.     [cr, lf]            (2573TL;)&
  44.     [insert cr, lf]        (2573I;)|
  45.     [read console]        (R13%='';08%(=)(T@#|;08%T' 'TLTLL@#;);)#
  46.     [type comment]        (@TD;)C
  47.     [display at logon]        ('
  48. Compile a REC expression into a very stylized assembly
  49. language program, which can nevertheless be assembled
  50. by a specialized assembler. Either type an expression
  51. to be compiled, using parentheses and braces, or two
  52. file names, as =INPUT,OUTPUT. If INPUT.DAT has a REC
  53. program, it will be compiled and placed in OUTPUT.DAT.
  54. Only one file may be processed in a given session, but
  55. several examples may be input from the console. Type a
  56. single carriage return to quit.
  57. 'TL@&;)D
  58.     [write workspace]        (@&JZqt;)T
  59.                 (@@;) }%
  60.     [integer arithmetic]    {(+;)+ (-;)- (*;)* (/&L;)/
  61.                 (pGm/L1=nL1;0=n;n&:)|
  62.                  ((pGmJj(U);QD(O)I;npGmEDZQD(O)IjnpGmI;
  63.                  n@@#I)nLJZ;;) } #
  64.     [save & init variables]    (pGpGm$rm0&$S;) (
  65.     [reinitialize variable]    (pG$r0=L;LnL0&$S;) :
  66.     [undefine variable]        ($r0=;LnL;) )
  67.     [compare/define variable]    (pG$r0=ZQzml&$S;&LyGEz;) ]
  68.     [body of variable search]    (pG$r(0=)yG(E;&L)z&L@=L;pG$r(0=;LL)
  69.                   Z<((&pGm&n(F;''mZz<)jJQmpGl&$S
  70.                   zZ<@=>;J>);nLA:0&$SL>)>LL;) >
  71.     [body of variable search]    (pG$r(0=)yGEz@=L;pG$r(0=;LL)
  72.                   Z<((jJQmpGl&$S
  73.                   zZ<@=>;J>);nLA:0&$S>)>L;) <
  74.     [insert variable]        ($ryGI;) [
  75.                 
  76. [individual cases]
  77. {(0@( 1@( {(0@: 1@: ;); (
  78.         @;(J2573TL'A:'TLZqtj()JZD;);
  79.         @;(J(A)JZD;);
  80.   [space, <,>]  @;(J [or] Z<(' 'Ez; J','Ez;>)> [or] 0@]JZD0@[;):
  81.   [number]    @;(J [and] Z<(@c jJ><0@](A);>)> [and] 1@]JZD'/call NU/db   'I39%I0@[39%Iz<1@[@AZ>;);
  82.   [quote]    @;(J [and] Z<( [or] Z<(@e; J@f;>)> [or]  jJ><0@](A);>)> [and] 1@]JZD'/call QU/db   'I0@[z<1@[@AZ>;);
  83.   [arroba]    @;(J'@'Ez [and] Z<(1(a;L)z jJ><0@](A);>)> [and] 1@]JZD'/call AR/db   'I39%I0@[39%Iz<1@[@AZ>;);
  84.   [comment]    @;(J@d0@]JZD0@[;):
  85.   [operator]    @;(J [and] Z<(@o jJ><0@](A);>)> [and] 1@]JZD'/call op$'I0@[z<1@[@AZ>;);
  86.   [predicate]    @;(J [and] Z<(@p jJ><0@](A);>)> [and] 1@]JZD'/call pr$'I0@['/jmp  #'Iz<1@[@AZ>;);
  87.   [colon]    @;(J':'Ez1@]JZD'/jmp  %/#:'Iz<1@[@AZ>;);
  88.   [semicolon]    @;(J';'Ez1@]JZD'/jmp  $/#:'Iz<1@[@AZ>;);
  89.   [parenthesis]    @;(J [and] Z<(@i jJ><'('Ez {[vbl] (')'Ez(A);) = (0@<;)}[vbl] (A);>)> [and] 1@]JZD'/%:'Iz<0@[@AZ>'/jmp  ##/$:/#:'Iz<1@[@AZ>;);
  90.   [brace]    @;(J [and] Z<(@j jJ><'{'Ez {[vbl] ('}'Ez;) = ('}'0@>;)}[vbl] (A);>)> [and] 1@]JZD'/call main/jmp  #/jmp  $'Iz<'[]'I0@[@BZ>z<1@[@AZ>'/$:'I;);
  91.   [more source] @;(J0@]JZD0@[z<z<@RZ>@CZ>;):
  92.   ;)} 0@) 1@)   nn$S nn$S;)} A
  93.  
  94. [string of definitions inside braces]
  95. {(0@( 1@( 2@( 3@( {(0@: 1@: 2@: 3@: ;); (
  96.         @;(J2573TL'B:'TLZqtj()JZD;);
  97.   [main]    @;(J'['Ez {[vbl] (']'Ez [and] Z<( [or] Z<(@i; J@j;>)> [or]  jJ><1@](A);>)> [and] ' 'Ez [and] Z<(@a jJ><2@](A);>)> [and] ' 'Ez3@];) = (']'0@>;)}[vbl] JZD'/'I2@[':'Iz<1@[@AZ>z<@EZ>z<'['I0@[z<2@[@pZ>']'I3@[@BZ>z<2@[@qZ>;);
  98.   [subroutines]    @;(J'['Ez {[vbl] (']'Ez [and] Z<( [or] Z<(@i; J@j;>)> [or]  jJ><1@](A);>)> [and] ;) = (']'0@>;)}[vbl] JZD'/pprg:'Iz<1@[@AZ>z<@EZ>'/main:'I0@['/call pprg'Iz<@rZ>;);
  99.   ;)} 0@) 1@) 2@) 3@)   nn$S nn$S nn$S nn$S;)} B
  100.  
  101. [exclude the portion of a file following ^Z]
  102. {(0@( {(0@: ;); (@;(J {[vbl] (26%Ez;) = (0@<;)}[vbl] JZD0@[;);;)} 0@)   nn$S;)} C
  103.  
  104. [push macro]
  105. {(0@( {(0@: ;); (@;(J0@]JZD'/lhld t$'I0@['/xthl/push h/lxi  h,'I0@[':/shld t$'I0@[;);;)} 0@)   nn$S;)} p
  106.  
  107. [pop macro]
  108. {(0@( {(0@: ;); (@;(J0@]JZD'/pop  h/xthl/shld t$'I0@[;);;)} 0@)   nn$S;)} q
  109.  
  110. [macro to transfer skip to stack]
  111. {(((JJZD'/jmp  $$/xthl/inx  h/inx  h/inx  h/xthl/$$:'I;);;) ;)} r
  112.  
  113. [main program]
  114. {
  115.   [alfanum]  ( [and] Z<(1(a;L)z jJ><' ''~'Mz(A);>)> [and] ;) a
  116.   [numeric]  ( [and] Z<(1(a;L)z jJ><'0''9'Mz(A);>)> [and] ;) b
  117.   [number]   ( [or] Z<('-'Ez; J;>)> [or] @b([ITR] Z<@b>:J>;)[ITR] ;) c
  118.   [comment]  ('['Ez([ITR] Z< [or] Z<(@d; J [and] Z<(1(a;L)z jJ><[not] (Z<  [or] Z<('['Ez; J']'Ez;>)> [or] J>)J>[not] Zz(A);>)> [and] ;>)> [or] >:J>;)[ITR] ']'Ez;) d
  119.   [s-quote]  (39%Ez([ITR] Z< [or] Z<(@e; J@f; J [and] Z<(1(a;L)z jJ><[not] (Z<  [or] Z<(39%Ez; J34%Ez;>)> [or] J>)J>[not] Zz(A);>)> [and] ;>)> [or] >:J>;)[ITR] 39%Ez;) e
  120.   [d-quote]  (34%Ez([ITR] Z< [or] Z<(@e; J@f; J [and] Z<(1(a;L)z jJ><[not] (Z<  [or] Z<(39%Ez; J34%Ez;>)> [or] J>)J>[not] Zz(A);>)> [and] ;>)> [or] >:J>;)[ITR] 34%Ez;) f
  121.          ( [or] Z<(@c; J@d; J@e; J@f; J'@'Ez1(a;L)z; J@i; J@j;>)> [or] ;) g
  122.          ( [and] Z<(1(a;L)z jJ><[not] (Z<  [or] Z<('('Ez; J')'Ez; J'{'Ez; J'}'Ez; J'['Ez; J']'Ez; J'@'Ez; J39%Ez; J34%Ez;>)> [or] J>)J>[not] Zz(A);>)> [and] ;) h
  123.   [paren]    ('('Ez([ITR] Z< [or] Z<(@g; J@h;>)> [or] >:J>;)[ITR] ')'Ez;) i
  124.   [brace]    ('{'Ez([ITR] Z< [or] Z<(@g; J@h;>)> [or] >:J>;)[ITR] '}'Ez;) j
  125.   [oper]     ( [or] Z<('!'Ez; J'#'Ez; J'$'Ez; J'%'Ez; J'&'Ez; J'*'Ez; J'+'Ez; J'/'Ez; J'<'Ez; J'>'Ez; J'D'Ez; J'G'Ez; J'I'Ez; J'J'Ez; J'K'Ez; J'L'Ez; J'P'Ez; J'Q'Ez; J'R'Ez; J'S'Ez; J'T'Ez; J'W'Ez; J'X'Ez; J'Z'Ez; J'\'Ez; J'^'Ez; J'_'Ez; J'c'Ez; J'g''z'Mz; J'|'Ez; J'~'Ez;>)> [or] ;) o
  126.   [pred]     ( [or] Z<('='Ez; J'?'Ez; J'A'Ez; J'B'Ez; J'C'Ez; J'E'Ez; J'F'Ez; J'H'Ez; J'M'Ez; J'O'Ez; J'U'Ez; J'V'Ez; J'`'Ez; J'a'Ez; J'b'Ez; J'd'Ez; J'e'Ez; J'f'Ez;>)> [or] ;) p
  127.  
  128.   
  129.          (z<8@['R'@%Z>;) R
  130.          ('/skip/#:/ret'I;) E
  131.   (0@( 8@( 9@( {(0@: 8@: 9@: ;); (
  132.     @;(J [or] Z<((A); J';'Ez;>)> [or] JZD'goodbye'I;);
  133.     @;(J'='Ez {[vbl] (','Ez9@];) = (8@<;)}[vbl] JZDz<8@['r''O'@%Z>z<9@['w''O'@%Z>z<9@['='Iz<z<z<@RZ>z<@RZ>@AZ>z<@EZ>'T'@%Z>'W'@%Z>z<'c'@%Z>;);
  134.     @;(J0@]JZDz<z<0@[@AZ>z<@EZ>'C'@%Z>z<'R'@%Z>;):
  135.   ;)} 0@) 8@) 9@)   nn$S nn$S nn$S;)} ~
  136. ('i'@%'D'@%'R'@%@~JZqt'c'@%;)  }
  137.  
  138. [end]
  139.