Skip to content
Atmel AVR simulator written in x86 assembly
Assembly C Makefile
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
example added 'hello world' to the self-test Jan 22, 2016
test Re-arrange the run-off areas so calls on invalid SP don't segfault. Jul 19, 2017
tinyTwofish @ c8d73fb track changes in tinyTwofish Mar 10, 2017
.gitmodules track changes in tinyTwofish Feb 2, 2016
LICENSE Initial commit Nov 3, 2014
Makefile added support for EEPROM memory May 15, 2017
avr_core_x86.s Re-arrange the run-off areas so calls on invalid SP don't segfault. Jul 19, 2017
ihexread.c small portability fixes May 28, 2017
ihexread.h small portability fixes May 28, 2017
ihexwrite.c small portability fixes May 28, 2017
tester.c Added handler for SIGQUIT (Ctrl-\). Jul 3, 2017


Developing AVR code usually involves a lot of simulation, by using programs such as:

fastavr is like these, but with the main design goals of raw speed and simplicity of use.


  • Supports all common AVR instructions (see below)
  • Optional user-definable behaviour of all AVR I/O ports
  • Interrupts and single-stepping
  • Possibility of simulating components using multi-threading
  • Much faster than a physical AVR


See the file tester.c; this reads an AVR program (in IHEX8 format) and executes it on a emulated Atmega2560, causing bytes written to USART0 to be written to the console. It also defines a watchdog timer that can be used to auto-reset/kill a program that is in a run-away condition (as described in Atmel's datasheets). Also emulated are the programmable timers TIMER0 and TIMER1, as well as EEPROM memory (for handling non-volatile data).


To build this project, you will need to have support for developing 32-bit programs installed. E.g. by installing libc6-dev-i386 on Debian.

Once you have that, this is likely to work:


Configuration options are found in avr_core_x86.s.

A quick test can be performed by running make selftest.


  • The S flag is always stuck at V⊕O due to the way fastavr handles the flags. This should only be noticeable when using SES/SEV/SEO/CLS/CLV/CLO or writing SREG via I/O-space

  • SPM and DES instructions are supported as hooks for C functions; see the des-support branch for a AVR-compatible emulation of the DES instruction.

  • No support for Reduced Core AVR; cycle count not correct for XMEGA microcontrollers.

  • Not all illegal opcodes will result in an error. Neither will out-of-bounds SRAM accesses.

  • The core has not yet been ported to x86-64.


Writing this pet project couldn't have been possible without Michel Pollet's excellent simavr.

Without the μNaCl project, testing this simulator wouldn't have been possible as well:

You can’t perform that action at this time.