Posts: 215
Joined: Sat Oct 14, 2017 9:57 pm

Disassember for AArch64

Sat Nov 18, 2017 12:32 am

Dear All,

Maybe my google kung-fu is not strong enough, but I couldn't find a decent disassembler for the Raspberry Pi 3. All that I've found (binutils, LLVM, Capstone) were huge, full of dependencies, most of them incomplete and difficult to use. Neither really suitable for a bare metal project.

So I've written one. It's really lightweight (less than 128k), yet it supports all ARMv8.2 instructions. It is as easy to integrate and use as it gets: a single C header file with only one function, licensed under MIT license.

Code: Select all

#include <aarch64.h>  // include the architecture to use
addr = disasm(uint64_t addr, char *str);
You pass the address of the instruction and a pre-allocated buffer. The function returns the address of the next instruction, and writes the zero terminated disassembled string into the buffer using only sprintf(). Really simple.

Writing the disassembler was easy. On the other hand I've spent 2 weeks with copying the instruction table out of that dull DDI0487 documentation. It took me endless hours often late at night. Although I've double checked it, there's a chance that I might mixed up some (possibly vector) arguments. If you find any error with the disassembly, please check the instruction table text file, and let me know. I'll fix it right away.


Return to “Bare metal, Assembly language”