Unit testing AVR assembly language

My “hobby project” is going well but the AVR assembly language that I’m writing has now got complex enough for me to really miss not having some form of unit testing framework in place. So I decided to remedy that I work out how I could write unit tests for various pieces of assembly language.

It turns out that with judicious use of ‘mock’ implementations of the code residing at various labels and traditional layering and separation of concerns I can build a set of unit tests that run in my AVR simulator and that either end up looping at a TestsFailed label or at a TestsSucceeded label depending on the outcome.

It’s been an interesting journey to get from assembly language newbie to feeling comfortable and then to the point where I understand enough to apply testing idioms that I’m comfortable with in C++ and C# to the assembly language code. I’m convinced that my progress will accelerate dramatically now that I can write tests for the code rather than simply single stepping in the simulator and monkey testing with the real hardware.