CONTENTS

Home
Updates
Software
Electronics
Music
Resume
Contact


YouTube
Twitter
GitHub
LinkedIn


naken_asm

Posted: July 25, 2012
Updated: July 3, 2023

Introduction

naken_asm is a lightweight assembler / disassembler with a focus on the following features:

  • Simple to compile (no dependencies, just type ./configure then make).
  • Simple to use (documentation here).
  • Support for many CPUs.
  • Include files for game consoles, microcontrollers, sensors, and other external devices.
  • Many samples to help out plus an MSP430 Tutorial.
  • Simulation for some CPUs.
  • More examples in the Java Grinder project.
  • Well supported.

Support for the following CPUs:

CPU asm disasm sim cycle counter Java Grinder Author
1802 /04/05/06 (RCA) RC RC   No No Michael Kohn
4004 (Intel MCS-4) RC RC   No No Michael Kohn
6502 / 6510 Stable Stable Stable Yes Yes Joe Davisson
65C816 Stable Alpha   Yes Yes Joe Davisson
6800 RC RC   No No Michael Kohn
6809 Stable Stable   Yes Yes Michael Kohn
68HC08 RC RC   Yes No Michael Kohn
68000 Stable Stable   No Yes Michael Kohn
8008 (Intel MCS-8) Stable Stable   No No Michael Kohn
8048 (MCS-48) RC RC   No No Michael Kohn
8051 / 8052 (MCS-51) Stable Stable   No Yes Michael Kohn
86000 RC RC   No No Michael Kohn
ARC Alpha Alpha   No No Michael Kohn
ARM RC RC   No No Michael Kohn
ARM64 Alpha Alpha   No No Michael Kohn
Atmel AVR8 Stable Stable Stable Yes Yes Michael Kohn
Cell BE (IBM) Stable Stable   No No Michael Kohn
Copper (Amiga) RC RC   Yes No Michael Kohn
CP1610 RC RC   No No Michael Kohn
dsPIC Stable Stable   Yes Yes Michael Kohn
Emotion Engine (Sony) Stable Stable   No Yes Michael Kohn
Emotion Engine VU Stable Stable   No No Michael Kohn
Epiphany (Parallela) Stable Stable   No Yes Michael Kohn
F-100L (Ferranti) Beta Beta   No No Michael Kohn
Java Beta Beta   No No Michael Kohn
LC-3 RC RC RC No No Michael Kohn
M8C (PSoC 1) RC RC   No No Michael Kohn
MIPS Stable Stable Stable No Yes Michael Kohn
MSP430 Stable Stable Stable Yes Yes Michael Kohn
MSP430X Stable Stable   No Yes Michael Kohn
Nintendo 64 RSP Stable Stable   No No Michael Kohn
PDP-8 Alpha Beta   No No Lars Brinkhoff
PDK13 RC RC   No No Michael Kohn
PDK14 RC RC   No No Michael Kohn
PDK15 RC RC   No No Michael Kohn
PIC14 RC RC   No No Michael Kohn
PIC18 RC RC   No No Michael Kohn
PIC24 Stable Stable   Yes Yes Michael Kohn
PIC32 (MIPS32) Stable Stable Stable No Yes Michael Kohn
Propeller Stable Stable   Yes Yes Michael Kohn
Propeller 2 Stable Stable   Yes No Michael Kohn
PowerPC Stable Stable   No No Michael Kohn
RISC-V Stable Stable   No No Michael Kohn
SH-4 RC RC   No No Michael Kohn
STM8 Stable Stable RC Yes No Michael Kohn
Super FX Beta Beta   No No Michael Kohn
SWEET16 RC RC   No No Michael Kohn
THUMB RC RC   No No Michael Kohn
TMS340 / TMS34010 RC RC   No No Michael Kohn
TMS1000 / TMS1100 Stable Stable   No No Michael Kohn
TMS9900 Stable Stable   Yes Yes Michael Kohn
SunPlus unSP RC RC   No No Michael Kohn
WebAssembly Beta Beta   No No Michael Kohn
Xtensa RC RC   No No Michael Kohn
Z80 Stable Stable Alpha Yes Yes Michael Kohn
  • Stable: The assembler has been used on a project.
  • RC: The assembler has been tested against another assembler for accuracy.
  • Beta: Code complete and should be good.
  • Alpha: The assembler has been started but not complete.

If anyone else has been using one of these assemblers / disassemblers and finds it stable please let me know so I can change the status to stable.

Input / Output file formats:

  • Intel HEX
  • ELF
  • Raw Binary
  • SREC
  • WDC
  • Amiga

Download
naken_asm-2023-01-11.tar.gz (Source)
naken_asm-2023-01-11.zip (Windows Binary)
naken_asm-2023-01-11-macosx10.15-x86_64.tar.gz (MacOSX)
naken_asm-2023.01.11-1.el7.x86_64.rpm (CentOS Linux)

The source repository is really the best place to get naken_asm since it will have all the latest bug fixes and features. It should compile easily on Linux, BSD, or any other OS. Just install gcc and type ./configure and then make.

Repository: git clone https://github.com/mikeakohn/naken_asm.git

Older
naken_asm-2022-10-29.tar.gz (Source)
naken_asm-2022-10-19.tar.gz (Source)
naken_asm-2022-04-16.tar.gz (Source)
naken_asm-2021-11-21.tar.gz (Source)

Documentation

The github repository has a docs directory with a list of all directives and some specific information for certain CPUs:
README

I also started an MSP430 tutorial that might be useful: MSP430 Tutorial. It's still a work in progress though.

Include Files

include/

How To Help

  • Use the assembler. Send me bug reports, suggestions, or just let me know you're using it.
  • Spread the word. Link to this page.
  • Create a package for a distribution (BSD/Linux etc).
  • Development boards and other toys would be fun :).

Samples

launchpad_blink.asm - Make 2 LED's blink with the MSP430 Launchpad
CamelForth - Brad Rodriguez has an implementation of Forth assembled with naken_asm.
Sega Genesis Demo - A demo of code written in Java, compiled with Java Grinder, and assembled with naken_asm.
Apple IIgs Demo - A demo Joe Davisson made of code written in Java, compiled with Java Grinder, and assembled with naken_asm.
Commodore 64 Demo - A demo Joe Davisson made showing a Commodore 64 demo written in Java, compiled with Java Grinder, and assembled with naken_asm.
TI99/4A Demo - A demo of code written in Java, compiled with Java Grinder, and assembled with naken_asm.
dsPIC Mandelbrots - Compute Mandelbrots with the DSP module of the dsPIC
Epiphany Mandelbrot - Compute Mandelbrots on a 16 core Epiphany on a Parallella board.
Playstation 3 Cell Mandelbrots - Compute Mandelbrots on 6 Playstation 3 Cell cores.
Playstation 2 Demo - A demo written in Java, compiled with Java Grinder, and assembled with naken_asm.
RISC-V - assembly on a HiFive1 board.
TRS80 Coco demo - A demo written in Java using the 6809 support.
Intellivision Demo - A breakout game written in Java and compiled for CP1610 / Intellivision with Java Grinder.
Intel 8008 - An iceFUN FPGA with an 8008 core running an assembly program.
Nintendo 64 demo - A demo written in Java, compiled with Java Grinder, and assembled with naken_asm.

Test Strategy

In order to give confidence that naken_asm isn't going to hinder anyone else's development, there are 3 different types of tests in the build system. The unit tests test small functions and modules outside the main naken_asm executable. For the comparison tests, there are text files with every single instruction with the output for each instruction assembled using another assembler (such as the GNU gas assembler), and a bash script compares the output of naken_asm with the output of these assemblers.

All tests are in naken_asm's tests/ directory.

Updates

July 4, 2023: Added test for PIC18 comparing it to Microchip's mpasmx. There's some weird stuff I found. The a value of some instructions seems to default to 0 and sometimes to 1. Also, this behavior doesn't always match what I've found in the documentation. So naken_asm will follow what the mpasmx assembler does unless I find out it's wrong. Also, the lfsr instruction is weird... it seems to store the k literal value big endian (upper 4 bits in the first word, lower 8 bits in the second word). All the other instructions seem to get divided up in 2 word instructions in a little endian format.

July 3, 2023: Added PIC18.

June 27, 2023: I recently did a big cleanup in the source code. The cleanup could help potentially turn naken_asm / naken_util into a library... possibly with Python hooks?

I've actually been contemplating changing this project from C to C++. Most of this project is alright a kind of object oriented C. If this could be C++... well, the simulator modules for example. There could be an abstract base class and all the different CPUs could be a subclass. The function names could be smaller (simulate_run_ebpf() would just simply be run() inside an Ebpf class) and the first paramter Simulate *simulate would be invisibly passed in as "this". Things like that could make it easier to read. If the std::'s didn't make the code run slower, they could possibly replace some awkward code.

On the negative side, I think it will compile slower and I have a feeling this project done in C possibly keeps some coders away.

October 29, 2022: Added support for Padauk PDK13, PDK14, PDK15. To test it an asm file was created with all the instructions for each arch and was assembled with Padauk's official IDE. It was then disassembled with the fppa-pdk-tools open source package. There is support for PDK16 but fppa-pdk-tools didn't seem to want to decode the .pdk file that the official IDE created, so there is no way to test it at the moment.

April 17, 2021: Added support for SunPlus unSP (used in some toys and consoles like V.Smile and I believe some Leapfrog systems). There are new tests that compare to the offical xasm16.exe assembler.

February 1, 2021: Added tests that compare the output of naken_asm with other assemblers for 4004, 68HC08, and CP1610. I upgraded those to RC and built a new release.

December 31, 2020: Added tests for Parallax Propeller 2 comparing the output to another assembler.

December 17, 2020: Added Parallax Propeller 2 support. No tests written yet so it's in a pretty unknown state.

November 29, 2020: I added Nintendo 64 RSP instructions. I used the SGI Nintendo 64 RSP Programmer's guide (official PDF from SGI) to add the instructions. To test I played around with 3 other assemblers (bass, armips, and rspasm from the n64chain project) but ended up using armips for different reasons.

Anyway, I tested naken_asm against the 3 assemblers and verified against the PDF. I'm 99% sure I got this right, but if anyone has some information please let me know.

May 17, 2020: I added TMS340 tests this weekend. Testing against the gspa assembler. I also added some TMS34020 instructions. I wish I had a board to test on :(.

May 10, 2020: I added TMS340 (TMS34010) this weekend. It was used in Mortal Kombat so I thought it might be cool to have it. Just need to do some testing to FINISH IT!

January 20, 2020: I added comparison tests for PSoC M8C (comparing against Cypress's own assembler) and 8048 / MCS-48 (comparing against asm48).

December 17, 2019: PSoC M8C was added. I haven't had a chance to try it yet and there are currently no tests that compare the output with other M8C assemblers.

November 2, 2019: Tests pass for Hitachi SH-4.

October 26, 2019: Added Hitachi SH-4. As of today, it's code complete but hasn't been tested. Should work with the Sega Dreamcast hardware.

March 5, 2019: Added MCS-48 .. seems this was some Intel instruction set used in things like 8048 in the Magnavox Odyssey 2.

Copyright 1997-2023 - Michael Kohn