Blazor WASM

Last year, I made VM1; a small assembler and a VM to run it with Antler & C#.

Microsoft release Blazor WASM preview which convert C# into Web Assembly and run inside a browser w/o server interactions. I confirmed the VM1 was smoothly referenced in a new Blazor WASM project and hosted.

Here is the demo site and github.

editor.razor)
editor.razor)
Compile and Run
...
private void CompileRun()
 {
     using (Stream s = GenerateStreamFromString(codeString))
     using (StreamReader sr = new StreamReader(s))
     using(MemoryStream ms = new MemoryStream())
     {
         // assemble
         AsmCompiler c = new AsmCompiler();
         c.Run(new AntlrInputStream(sr), ms);
         ms.Flush();
        int[] code = new int[ms.Length / 4];
        ms.Seek(0, SeekOrigin.Begin);
        using (BinaryReader binaryStream = new BinaryReader(ms))
        {
            for (var i = 0; i < code.Length; i++)
            {
                 code[i] = binaryStream.ReadInt32();
            }
        }
        // run
        Cpu cpu = new Cpu(code, 0, 1024, 1024, false);
        using(StringWriter sw = new StringWriter()){
            cpu.Run(sw);
            outputString = sw.ToString();
        }
    }
 }