This guide explains how to build, run, and test the ARMv8 simulator using Docker.
- Docker installed on your system
- The project files in the correct directory structure
- Ensure you are in the root directory of the project where the Dockerfile is located.
- Build the Docker image:
docker build -t armv8-simulator:latest .docker run --rm -it armv8-simulator:latestThis will start an interactive shell inside the container.
Once inside the container:
cd src
make clean # Optional: Clean previous builds
makeThe simulator can run bytecode files located in the inputs/bytecodes directory:
./sim ../inputs/bytecodes/eor.xAvailable bytecode files include:
- adds.x
- addis.x
- adds-subs.x
- ands.x
- beq.x
- blt.x
- eor.x
- movz.x
- subis.x
- sturb.x
Once the simulator is running, you can use the following commands:
go: Execute the program completely until haltrun <n>: Execute n instructionsmdump <low> <high>: Memory dump from low to high addressrdump: Register dumpinput reg_num reg_val: Set a register value?: Display helpquit: Exit the simulator
Example session:
ARM-SIM> go
Simulating...
Simulator halted
ARM-SIM> rdump
The project includes reference simulators for comparison. From the main directory:
./ref_sim_x86 inputs/bytecodes/addis.xNote: The reference simulator filename depends on your host architecture (ref_sim_x86 for x86 systems).
If you have your own ARMv8 assembly code (.s files), you can compile it using the provided tools:
cd inputs
./asm2hex your_code.s > bytecodes/your_code.xThen run it with the simulator:
cd ../src
./sim ../inputs/bytecodes/your_code.xIf you see "Exec format error" when trying to run the simulator, it means the binary was compiled for a different architecture. Make sure to:
- Run
make cleanto remove the old binary - Run
maketo rebuild for your current architecture - Try running the simulator again
First, compile the simulator:
cd src
make
cd ..To run the tests, use the following command:
./compare_simulators.sh inputs/bytecodesThis will compare the output of the simulator with the reference simulator for all the bytecode files in the inputs/bytecodes directory.