Rickta59 aims to get the most of his MSP430 by writing code in Assembly. Knowing how many instruction cycles each ASM statement takes to execute becomes tedious for larger programs. With Rocket4Kid’s recommendation, he was able to use naken430asm in combination with the msp430-gcc bin utilites.


This is an open-sourced assembler / disassembler / simulator for the MSP430 series of microcontrollers from Texas Instruments. The goal of this project is to have a completely cross-platform assembler with the exe (naken430asm) under 50k and to have a cross-platform 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 and I have built in simulation to help show how the binary code will flow on the chip and how many cycles it will take to execute.

First, compile your code as usual and produce an ELF file. We will assume your file is called blink.elf. Once you have an ELF file, convert it to an intel hex file using this command:

[plain]msp430-objcopy -O ihex blink.elf blink.hex[/plain]

Nake430util can then be used to get a listing of the asm instructions in the hex file along with a cycle count using the following command:

[plain]naken430util -disasm blink.hex > cycle_listing.txt[/plain]

The cycle_listing.txt will contain something that looks like this:

[plain]Addr Opcode Instruction Cycles
——- —— ———————————- ——
0xc000: 0x4031 mov.w #0x0400, SP 2
0xc002: 0x0400
0xc004: 0x4215 mov.w &0x0120, r5 3
0xc006: 0x0120
0xc008: 0xf375 and.b #-1, r5 1
0xc00a: 0xd035 bis.w #0x5a08, r5 2
0xc00c: 0x5a08
0xc00e: 0x403f mov.w #0x0000, r15 2[/plain]

Michael Kohn is the author of Naken430ASM and you can find his project page here. He also has alot of other interesting projects, our favorite being the Linksys Quadcopter.