Posted: June 14, 2010
Updated: July 21, 2012
naken430asm has been replaced by
naken_asm. Please visit the
naken_asm page for more information.
This is an open-sourced assembler / disassembler / simulator
for the MSP430 series of microcontrollers from
The goal of this project is to have a completely cross-platform
assembler with the exe (naken430asm) under 100k supporting both
the 16 bit MSP430 and 20 bit MSP430X instruction sets and to have
disassembly utility (naken430util) along with it to help with debugging
and a bit of profiling. The naken430util, when disassembling, shows
how many CPU cycles each instruction will take (MSP430 only) and I have
simulation to help show how the binary code will flow on the chip and
how many cycles it will take to execute.
I also wanted to add the ability to program and
debug the chips from naken430util, but I may just leave that for the
NOTE: All new development is being
done on the naken_asm project.
Download (October 30, 2011)
naken430asm stable release
naken430asm-2011-10-30.tar.gz (Source Code)
naken430asm-2011-10-30-macosx10.6-x86_64.tar.gz (MacOSX 10.6)
naken430asm-2011-10-30.zip (Windows XP/Vista/7)
Alexander Zhevak is working on some include files for naken430asm.
They can be downloaded from:
git clone git://github.com/zhevak/naken430-inc.git
I've moved the UART, SPI, DS18B20 and such samples to the
naken_asm git repository.
clock_thermometer.asm - Talking alarm clock thermometer.
msp430_sirc.asm - Reading SIRC data from a Sony remote control.
Bluetooth Thermometer - Bluetooth module hooked up to an msp430g2553.
Syma S107 No Fly Zone - IR Jammer for Syma S107 Helicopters.
Brushless Motor - Example of spinning a brushless motor with an MSP430.
LCD - Olimex MSP430-4619LCD.
Walking Robot - Vinod's 2 servo walking robot using the TI Launchpad.
Math Routines - Joe Davisson made some math funcions for the msp430.
naken430asm is distributed under the GPL license.
Assembling, Disassembling, Simulating
A program can be assembled from the command line with a simple:
naken430asm -d launchpad_blink.asm
The -d option will create an .ndbg file which helps naken430util when
using the -list option. It can be left out. The -o option can be used
to name the output file something other than out.hex. To disassemble
the code, simply type:
for interactive mode or:
./naken430util -disasm out.hex
to disassemble the out.hex file or
./naken430util -list out.hex
to disassemble the out.hex program and print the source code to the right of it using the .ndbg file.
The simulator allows you to show how your program will run. It gives a
view of all the registers and how many CPU cycles have passed, along with
the current instruction that executed and the next few in memory. To
test the simulation, after assembling launchpad.asm type:
This will load the out.hex file and set the CPU speed to 1Hz. The run
command of course will start the simulation. To pause it just press Ctrl-C.
To run in single step mode:
One instruction is executed and the simulator breaks. Pressing enter
or typing 'run' again will execute one more instruction. If there is a
function needing to be profiled at location 0xf010, typing: call 0xf010
will execute it. The program will stop running at the RET of the function.
Three other useful commands are call, push, and set. To push something
on the stack just do: push 0x1000 for example to push 0x1000 to the stack.
To set the value of a register: set pc=1000 or set r5=0xffff. To call
a function: call 0xf034 to call a function at location 0xf034. This
pushes the return address 0xffff on the stack and sets PC to 0xf034.
When the simulator sees PC==0xffff it returns back to you so the number
of clock cycles it took to run the function.
There are 4 commands for reading and writing memory: bprint, wprint,
bwrite, wwrite. So to write 5 bytes to location 0x1000, I could type:
bwrite 0x1000 100 102 143 0 5
and I can confirm it's written by typing: bprint 0x1000
For reading and writing word sized data, wprint and wwrite work the
Like other MSP430 assemblers, naken430asm accepts C style #define, #ifdef,
#if defined(). An example would be:
#define BLAH 50
mov.w r1, r12
mov.w r3, r12
#if defined(SOMETHING) && !defined(ANOTHER) && BLAH>50
mov.w @r12+, r3
Standard assembler syntax "equ" is also accepted too:
BLAH equ 50
Also .macro / .endm works like the following:
mov.w #5, r10
mov.w #6, r11
mov.w #a, r10
mov.w #b, r11
Data bytes and words can be done with db (or dc8) and dw (or dc16).
Chunks of databytes that default to 0 can be set with ds, ds8, ds16.
Strings in db sections are not null terminated.
db "Copyright 2010 by Michael Kohn", 0, 5, -9
dw 100, 2000, 400, 9
Files can be included with a .include "filename.h".
Comments can be done with a standard assembler ; (semicolon) or with
standard C's // and /* */.
As with other assemblers, org or .org is used to tell the assembler
what address a piece of code starts on.
Hex number can be written with either 0xFFD2 or 0FFD2h. Octal
numbers can either start with 0 or end with q: 070 or 70q. Binary
numbers can just end with a b: 11110000b.
|.db <data bytes>
||.dw <data words>
|.ds8 <data byte>
||.ds16 <data words>
||.macro <name> (opt. params)
... To be completed ...
Copyright 1997-2019 - Michael Kohn