tuwien2020 / tgi-pages

Open tools for the TGI course at the TU Vienna
https://tuwien2020.github.io/tgi-pages/#/
The Unlicense
12 stars 5 forks source link

Micro16 Compiler #22

Open stefnotch opened 3 years ago

stefnotch commented 3 years ago

Here is a pretty interesting Micro16 compiler, I guess it might be worthwhile1 to work on that one and compile it to webassembly

https://github.com/zero9178/Micro16C

[1] Worthwhile for anyone who still has TGI

stefnotch commented 2 years ago

Some quick notes regarding the Micro16 grammar (as far as I can tell)

instruction; instruction; instruction; instruction; ...

AC <- lsh(~MBR); MAR <- 1; rd; goto 139

instruction = rd | wr |
  (register <-)? math |
  (if (Z|N))? goto number

math = shift(arithmetic) | arithmetic
shift = lsh | rsh
arithmetic = register | unaryop register | register binaryop register
unaryop = ~
binaryop = + | &

and then we need to do a whole lotta extra validations (e.g. cannot write to register -1)

Defining an isomorphism is probably impossible, since

RDWR MS
0     0  = ""
1     0  = "" (warning?)
0     1  = wr
1     1  = rd
Fancy11111 commented 2 years ago

Maybe we can ask for a language grammar from the source? 🤔