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.

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);
        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()){
            outputString = sw.ToString();

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.