I play with Arduino Micro. I write my programs in directly in machine code, in binary editors (yes, I know that there are more easy ways to program an Arduino, I do it for fun and learning). Often my programs work, but if not, then I would like to run them on an emulator to understand what's exactly going on under the hood. Is there any Arduino emulator that accepts hex files with compiled program and can execute it? I already looked at tools mentioned at Can I program for Arduino without having a real board? , but as far as I see, they are simulators rather than emulators and I can't use compiled binary programs in them.

  • Are you sure you are not writing Opcode? As machine code is literally typing in numbers. For example, there are no "labels" let alone "goto labels". When writing in machine code, generally all branches need to be calculated to either a relative or absolute memory address. – st2000 Dec 15 '18 at 14:53
  • Yes, I am sure that I am not writing opcodes, I am writing in machine code - this is why I mentioned that I use binary editor (I tried to be clear about it). – user983447 Dec 15 '18 at 15:30
  • Ok, understood. Going on, I answered your question generically. But I see you were asking about the ATmega32U4. If I were Microchip, I wouldn't publish how my processor worked. That's intellectual property. So it would be surprising to find a working software emulator available for this specific processor. As I send in the answer, most developers simply work with the actual processor using its JTAG interface. – st2000 Dec 15 '18 at 15:35
  • Hint: Search github, here is an example of a simulator that you could continue working on: github.com/buserror/simavr – Mikael Patel Dec 15 '18 at 16:17

There are many different processors used in making many different types of Arduino boards. So there is no one way to write Arduino machine code.

There are emulator for simpler processors available for the asking. But, while they work, it is not believe they claim to be totally accurate.

At one point in processor development history, ICE machines were widely used. This is where a real processor is modified to allow access to internal controls and registers. (This actually sounds like the answer to your question.) However, as processors grew in speed and complexity, this approach grew out of favor.

Currently, most processors are built with extra internal circuitry and interface to break program execution for debugging purposes. JTAG is one such industry standard / example.

So, while the question has merit, the common practice is likely not to run code on an emulator, but to run it on the processor using the JTAG interface and an IDE running on a host-computer / work-station.

  • The in-circuit-emulators were very expensive and never 100% accurate (for example different timing for external signals), while the JTAG is already in the microcontroller for free. – Jot Dec 15 '18 at 15:35
  • Good points @Jot. And I can attest to the timing difficulties. – st2000 Dec 15 '18 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.