How to Install Arithmetic Expression Compiler


  1. Read the notice on the web-page. And take it seriously. While you can safely experiment with programming in JavaScript on a computer you care about, I’d not recommend you to practice C or, maybe even worse, Assembly on a computer you care about. So, use some older computer, save all the important data on it to an USB stick, and, if it’s not so old that it can’t run it, install some software to protect other programs on it. I am saying this from my own experience, just installing an incompatible C IDE (for example, the newest version of Dev-Cpp on Windows XP) can lead to registry errors preventing important programs such as Microsoft Word from working.
  2. Install GCC, CLANG or some equivalent program. Don’t be afraid to install the newest versions of those programs on a computer with 128 MB RAM (you don’t have to spend a lot of time trying to browse the modern web using Internet Explorer 6 and find the older versions of those programs), those programs are actually designed to be run on microcontrollers such as Raspberry Pi. GCC can, for instance, at the time of writing, be downloaded here (there are many different versions of GCC, but Arithmetic Expression Compiler should be installable using any of them), and CLANG can be downloaded here. The main difference between them is that Clang attempts to use the features of modern computers to run faster on them if those features happen to be available (at the expense of running slower than GCC on older computers), while GCC stays fixed forever in its time. I personally use CLANG on MAC and GCC on PC. I believe even DJGPP run on DOS (but good luck installing a programming tool on DOS) would do the trick, but I haven’t tested that. You will also need Duktape, and you have the (at the time of writing) newest version of Duktape in this ZIP (because it’s legal to host Duktape on your website, but it’s not legal to have GCC or CLANG binary files on it). You can download the newest version of Duktape here (their website isn’t usable in older browsers).
  3. If the installer didn’t do that automatically, edit the registry to add (not replace with) the path where the program (GCC, CLANG…) was installed to the (depending on the Operating System you are using) %PATH% or the $PATH variable. That makes compiling C programs a lot easier! If you can’t edit the registry (even after logging on as an administrator and blocking the antivirus software), a work-around might be to type SET PATH=%PATH%;<the-path-of-the-installation> every time you open Command Prompt.
  4. Unzip this ZIP archive into some folder, and then open the Command Prompt. In case that folder is on the default drive (usually C:\), type: <name-of-the-drive>: (not <name>:\). Then, type cd <the-path-to-the-folder> (without the square brackets, of course!).
  5. To install the command-line calculator, type <GCC-or-CLANG> -o calc calc.c duktape.c (it’s important to type that all in the same line). To install the Arithmetic Expression Compiler, type <GCC-or-CLANG> -o aec aec.c duktape.c. Depending on the configuration of the computer you are using, GCC or CLANG should now run for several seconds, but they should not output anything. If you find GCC and CLANG too slow, you can experiment with some faster alternatives, such as TCC (but be aware that Duktape is not fully compatible with it).
  6. In order to actually use it, you also need to download and install FlatAssembler (if you haven’t already).
  7. To test it, type in Command Prompt aec euclid.aec. It should generate a file named euclid.asm. Open that file using FlatAssembler and click Compile and Run. If everything is fine, you should get a command-line program asking you to enter two numbers 1-100 and printing their greatest common divisors.
  8. You can move the aec.exe and calc.exe files anywhere you want on your computer, but you have to also move the compiler.js and control.js files into the same folder.
  9. To get the idea of the syntax which Arithmetic Expression Compiler accepts, open euclid.aec in a text-editor and study the comments. I’m assuming you are somewhat familiar to Assembly :-).
  10. Feel free to modify any part of Arithmetic Expression Compiler and post the modified version on your website, but please include a link the original version (https://flatassembler.github.io/compiler.html).