I'm trying to write emulator for ARM Cortex M3. How can I read the binary file then decode it?

1.2k views Asked by At

I'm trying to write emulator for ARM Cortex M3. How can I read the binary file then decode it? I want to use binary files as a resource of my emulator. I created a project with Atmel Studio and I compiled it. Now, I have a .hex file. I can also convert this file to binary file with hex2bin. After that, how can I use that binary file for fetching and decoding instructions ? I'm working on Visual Studio with C/C++.

1

There are 1 answers

0
Cédric Julien On BEST ANSWER

First, need to mention that writing an emulator for a processor is not an easy task, other have already spend lot of time on it, you can take a look at QEmu for example. One project is currenlty using Qemu to emulate a Cortex M3 based board, the ZephyrProject.

An intermediate step, could be to use a tool that already understand/decode hex or bin file, and Radare is one of those kind of tool. With it you will be abvle to disassemble many elf files and get the instructions from it (that you'll then have to emulate ;) ).

That said, if you still really want/need to make the emulation, and start to read and understand the hex or binary files, the first thing to do will to study the Intel Hex file format (yes, even ARM is using this Intel format ;) ). You can find the official specification here or in the technical support website of ARM.

Have fun ;)