I would like to simulate ARM code. For example, I want to run code like this:
MOV R0, #5
ADD R0, R0, #1
//somehow output R0
And it would output 6 on some software on my Ubuntu. Is it possible?
ARMSim# is a desktop application running in a Windows environment. It allows users to simulate the execution of ARM assembly language programs on a system based on the ARM7TDMI processor.
ARM Cortex-A Series Programmer's Guide for ARMv7-A Assembly language is a low-level programming language. There is in general, a one-to-one relationship between assembly language instructions (mnemonics) and the actual binary opcode executed by the core.
Keil MDK can be used to simulate the ARM codes. It provides a Simulate/Debug perspective which can be used to probe the ARM register set, memory content, etc...
MDK-Lite evaluation version is available free of cost for a maximum code size of 32KB.
Linux version of MDK is not available. But Keil MDK works perfectly over WINE in Ubuntu.
Step 1: Install wine on Ubuntu
Open a terminal and type:
sudo apt-get install wine
Step 2: Download Keil MDK.
Step 3: Install MDK
Right-Click on MDK executable file and select "Open With Wine Windows Program Loader" option.
Step 4: Invoke Keil uVision MDK on Ubuntu
Open a terminal and type:
wine ~/.wine/drive_c/Keil/UV4/Uv4.exe
Step 5: Install Flash Magic (Optional)
Flash Magic is a tool used to download software for Keil boards. Download Flash Magic Software and install it on wine (refer previous steps).
Create a COM1 link to serial port. Open a terminal and type:
ln -s /dev/ttyS0 ~/.wine/dosdevices/COM1
Step 1: Create a Keil UVision project for ARM7 target.
In Keil UVision tool bar select Project --> New Project.
Navigate to a location where you want to create this project.
Enter a project name and click Save.
Select ARM --> ARM7(Little Endian) as device for Target. Click OK.
Step 2: Create an assembly source file for the target
In Keil UVision tool bar select File --> New. Add the following code to the newly created file:
AREA text, code, readonly
ENTRY
MOV R0, #5
ADD R0, R0, #1
END
Provide tab-space before each assembly statement as done above. Save the file with '.s' extension.
Step 3: Add source file to project
In Project window (located left side of UVision), Right click on Source Group 1 and select "Add Files to Group Source Group 1" option.
Select test.s and click 'Add'. (Select File Type as ASM Source file)
Step 4: Build source file
In Keil UVision tool bar select Project --> Build target or Press F7 to compile the source file.
Step 5: Simulate/Debug application
In Keil UVision tool bar select Debug--> Start/Stop Debug Session or Press Ctrl + F5.
The debug perspective opens up with a Register view at left side, Code View at center, Memory view at right bottom, etc...
Use the debugging keys to execute the code:
Observe Register view at end of program execution:
In Keil UVision tool bar select Debug--> Start/Stop Debug Session or Press Ctrl + F5 to come out of Debugging Perspective.
If you build it into an actual executable then you can use QEMU's ARM emulator to run it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With