A while ago I wanted to learn ARM assembly and after some search for existing tools to execute and debug instructions, finally decided that the best way to learn an assembly would be to write an emulator for it.
C seemed a good choice, as being a middle level language, it provides high level constructs while still providing low level details that are closer to assembly language.
If you need more information about ARM assembly Pete Cockerell’s ARM Assembly Language Programming has almost all the information one may need.
It is not a complete emulator, but has the following functionalities to kick-start the journey of learning ARM assembly.
-Pipeline: Size 4
-Reserves memory locations for; Interrupt instructions and user instructions.
-Counts the cycles for each instruction and total cycles.
-Data processing instructions: Sets the overflow and carry flags.
-Branch instructions: Uses stack to store the link data if need.
-Data transfer instructions
-Interrupts instructions: Executes the interrupt instruction in the input instructions set or accepts hardware instruction before fetching a new instruction.
-Prints out the registers, user accessible memory, stack memory and the status flags. “debugEnabled” and “instructionLogEnabled” variables can be switched on for farther information in the output.
Please download the source code or access it on GitHub below. Feel free to use/edit it as you may.
The ‘ArmEmulator.c’ file in the ‘src’ folder includes all the required code. I used gcc to compile the C code, after installing it, you may just edit the folder path in the ‘Compile_ArmEmulator.bat’ and use it to compile the code.