Meta ii from 1967

I have finished a version of the ‘Meta II’ compiler with lower case letters.! is constant
to EOL.
Rather than byte codes, I compile to assmbly code. JSV is a subroutine call.
I did how ever need to add a new branch instruction LIT R #n
to permit in-line constants. R = PC, PC = PC + #n
FCS " string " is a ASM macro for string constants. It is just over 4K long.

! META II 67
.SYNTAX PROGRAM

OUT1 = 
      
     '*1' .CRD('JSV A Z GN1')
    / '*2' .CRD('JSV A Z GN2') 
    / '*'  .CRD('JSV A Z CI') 
    / .STRING .CRD('FCS ' *)
      .CRD('JSV A Z CL') 
    ;

OUTPUT = 
      ('.CRD' '(' $ OUT1 ')' 
    / '.LABEL' .CRD('JSV A Z LB') OUT1)
      .CRD('JSV A Z OUT') 
      / '.TTY' '(' $ OUT1 ')'.CRD('JSV A Z TTY') 
    ;

EX3 = .ID .CRD('LEA X Z ' *) .CRD('JSV A Z CSR')
    / .STRING .CRD('FCS ' *)
      .CRD('JSV A Z TST')
    / '.ID' .CRD('JSV A Z ID') 
    / '.NUMBER' .CRD('JSV A Z NUM') 
    / '.STRING' .CRD('JSV A Z SR')
    / '(' EX1 ')'
    / '.EMPTY' .CRD('LD. A #1') .CRD('ST A Z SWITCH')
    / '$' .LABEL *1   EX3 .CRD('LD A Z SWITCH') 
      .CRD('BNE A #' *1) .CRD('LD. A #1') .CRD('ST A Z SWITCH')  
    ;

 EX2 = (EX3 .CRD('LD A Z SWITCH') .CRD('BEQ A #' *1)
       / OUTPUT)
     $ (EX3 .CRD('JSV A Z BE') / OUTPUT)
     .LABEL *1 ;


EX1 = EX2 $('/' .CRD('LD A Z SWITCH')  .CRD('BNE A #' *1)EX2)
    .LABEL *1 ;

ST = .ID .LABEL * '=' EX1 ';'  .CRD('JMP A Z RR') ;

PROGRAM = '.SYNTAX'
  .TTY('meta 67 <CARD.IN> <CARD.OUT>')
 .CRD('INC M67V.ASM')
 .ID .CRD('LEA X Z ' *) .CRD('JSV A Z CSR')
 .CRD('BRA A #ENDOK')  $ ST '.END'  .CRD('END')
  .TTY('Meta 67 finished')
 ;

.END

Ben,

2 Likes

I’ve had it on my mind to build an implementation of this myself, since Alan Kay talked about it. I’ve been taking steps toward it through other projects.

Over the summer, I built what I’m calling a “Parr VM”, named after Terence Parr, who demo’d a simple VM of his own design in Java, years ago. Now, I’m writing an assembler for it, but in the process, I decided to build a couple state machines I devised, so that I can program the assembly language using a very simple pattern language, and spec’ing out a grammar.

The state machine project has turned into a larger one than I anticipated, quite a bit larger than the VM!

2 Likes