How to compile and run a program written in X.
- You need to have GCC or another C compiler installed.
- This explanation will be written using linux commands. There will be similar commands and tools for your own operating system.
How to Compile
- Download and extract this zip file containing the tools you will need.
- Open the terminal to this folder and compile the emulator file called 32bitSimulatorForBinaryImage.c by typing gcc 32bitSimulatorForBinaryImage.c (and pressing enter) or using your favourite compiler.
- Copy the X compiler binary to a.bin so it can be run by the simulator with
cp x_to_16bitHex_compiler.bin a.bin
- Run the simulator executable, streaming the x source code in to standard input, with ./a.out < io.x. This will produce two files: sim2 and sim3. These are the hex input memory images for the machine.
- Now compile 16bitSimulatorForHexImages.c with gcc 16bitSimulatorForHexImages.c.
- Run the compiled executable with ./a.out.
Alternatively, run the bash script ./compile <source_code_filename.x>
to execute these commands automatically.
How to Run the Executable
There are three options on where to run your executable:
- Via C: You can execute the code via the C Simulator as outlined in steps 5 and 6 above.
- Via Java: We have implimented a model of the machine in a simulator called ModuleSim.
The model for the BigHex Machine can be found via a Github Repo. You can load the ram image files (produced above) in to the memory modules and execute the code inside the simulator.
How to run code on the Big Hex Machine
- While the Big Hex Machine is running connect to the wifi network "bighex". This does not require any credentials. Please be aware there is a slight delay between the time the machine is turned on and the "bighex" access point appearing.
- Open a web browser and type the address: http://bighexmachine.com. You may notice that any other web requests will get redirected to this page.
- After the web app has been requested by the browser the 'Big Hex Control Panel' should appear. Click on 'Load an X Program' and then enter your source code into the main text area.
- Clicking on the submit button will send your X Program to the machine and compile it. The machine will also automatically load the machine code into the machine's memory - you should see this happening on the machine itself.
- Going back to the control panel will then enable you to start the machine executing. You can also change the clock speed to view the process in slow motion.