Blogs » The Idea Behind CAIE Assembly Emulator
A few days ago I released CAIE Assembly Emulator. Well, essentially I've seen lots of lots of pseudocode compilers for the 9618 syllabus, but haven't seen any assembly ones. So I thought, why not make one?
I decided to make a WASM web app not only because me being a fan of Rust and egui, but also for security concerns... Here's what happened: my club created an online pseudocode compiler which sends code to server for execution. However, a user executed file operations that modified system files on the server, and the server was under maintentance for a few days. So I wanted an app that runs entirely on the client side.
Deployment...
Creating and testing the app went fairly smoothly, but problem occured when I tried to deploy it:

...the file was ~60MiB, and the server was sending it to every visitor. How could this happen? I was suspicious of my toolchain until I see this in my code:
fonts.font_data.insert(
"source_han_sans_font".to_owned(),
egui::FontData::from_static(include_bytes!("../assets/fonts/SourceHanSansSC-Regular.otf")),
);
fonts.font_data.insert(
"material_design_icons_font".to_owned(),
egui::FontData::from_static(include_bytes!("../assets/fonts/MaterialDesignIcons.ttf")),
);
fonts.font_data.insert(
"material_symbols_font".to_owned(),
egui::FontData::from_static(include_bytes!("../assets/fonts/MaterialSymbolsOutlined.ttf")),
);
CJK font and symbol fonts... it turned up to be copy-pasted code from another project, and I forgot to remove them. The fonts were huge, but the CJK font and most of the symbols were not even used in the app! Removing the CJK font was easy, but a few symbols were still used. I had two options:
- Remove the symbols and forget about icons
- Try to make a subset of the symbols
I love those icons in my app, so I decided to make a subset. Using Glyphs 3, I set those unused glyphs to non-exporting using a filter. Now, export... wait, the exported TTF font is unusable.
I noticed that the glyphs are not assigned to any codepoint (why?), but anyways manually assigning those Unicode codepoints went fine.
Now the WASM is 2.2MiB, and the site is up and running. Hooray!
The unsatisfactory workflow
Currently I have to upload the source code to my git repository as well as the compiled web app (due to Vercel automatic deployment stuff). I'm still looking for a way to automate WASM compilation (perhaps GitHub Actions), but... the uni application season is incoming, so it might be done at some point.