|
CONTENTS Home Projects Electronics Graphics Java Java Mobile Android Other Stuff Resume Music Pictures Contact Follow @mikeakohn |
MSP430 AssemblerMore electronics projects on mikekohn.net here. Posted: June 14, 2010
Contents
Introduction Introduction 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 100k supporting both the 16 bit MSP430 and 20 bit MSP430X instruction sets 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 (MSP430 only) 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. I also wanted to add the ability to program and debug the chips from naken430util, but I may just leave that for the MSPDebug project. I could really use help right now with people testing out the 2012 version of the assembler and report bugs to me so I can stabilize the new version of naken430asm. Also, if anyone would like to to buy me this MSP430 (http://www.metawatch.org/) watch (or convince them to send me one :) so I could test naken430asm on it, I would be grateful also :). NOTE: All new developement is being done on the naken_asm project. Download (October 30, 2011) Alexander Zhevak is working on some include files for naken430asm. They can be downloaded from: git clone git://github.com/zhevak/naken430-inc.git enc28j60.inc - I've been working on an ethernet project with this Microchip ENC28J60 chip. I made an include file for it if anyone wants it. Samples
launchpad_blink.asm - Make 2 LED's blink News August 5, 2012: Moved new development to naken_asm July 8, 2012: On July 4, I added ARM disassembly to this project and started up on ARM assembly. Today I have most dsPIC instructions assembling and disassembling but because dsPIC has 12 bit memory, it's useless right now. My goal for the weekend was to have my first program working on a chip, but I have to fix this issue first. I'm also trying to come up with a new name for the project since the new version will assemble embedded CPU's other than MSP430. MSP430 is still my favorite btw, just thought it would be cool to add more CPU's. May 27, 2012: I assembled my first program today using MSP430X 20 bit extensions and it functions on this Olimex MSP430-4619LCD board. I added .binfile as a directive to insert binary files (in my case images to display on the LCD display). It ends up that using .binfile is quite a lot faster than creating .inc files with .db parts. May 16, 2012: I'm code complete on the MSP430X instruction set. I need to test it a bit before releasing. Next I have to add the memory paging featuer so it can access more than 64k without wasting memory. Last two things is to update hexfile and elf output to support it. Probably I'll also have to fix problems in the disassembler with MSP430X. April 29, 2012: Today I rewrote the whole way memory works in naken430asm. Originally I just allocated buffers the size of the addressable memory of an MSP430 device. Now it's all abstracted out into a structure and set of functions. The ultimate plan is to allcoate memory in 8k pages only when a write happens at an address in that area. I bought this Olimex MSP430-4619LCD board so I can test MSP430X instructions on it and started working on an msp430x4xxx.inc file for it. April 24, 2012: A couple months ago I rewrote the memory management for the macros and address lookup table. I had been slowly trying to retrofit MSP430X instructions into the msp430_asm.c file, but it was really messy. So on Sunday I rewrote msp430_asm.c as msp430x_asm.c. The code is 10000 times cleaner and so far it's working so I think I'm going to post a preview of it later in the week so people can help me test it. I plan on adding MSP430X instructions into it after that and I started implenting another CPU. Also, I plan to change the way it assembles into RAM. Currently it just allocates 64k of memory and assembles code wherever in that memory chunk. I think instead I will allocate 8k pages and hook them together. Hopefully this brings me closer to releasing an updated stable version soon :). January 16, 2012: Just wanted to post a message so this project doesn't look abandoned. The assembler appears to be quite stable. I've been using it for a while and haven't had a complaint in a while. Currently I've been working (slowly) on MSP430X support which is... eh... not as clean of an instruction set as straight 16 bit MSP430 is, so this hasn't been very fun. So I got an email from Gregory Davill with some tips on include files with naken430asm. He writes: The standard headers include a "#include <iomacros.h>" which defines how the registers are defined. By replacing that line with these six macros your assembler works perfectly with the new header. #define sfrb(x,y) x equ y #define sfrw(x,y) x equ y #define sfra(x,y) x equ y #define const_sfrb(x,y) sfrb(x,y) #define const_sfrw(x,y) sfrw(x,y) #define const_sfra(x,y) sfra(x,y) October 24, 2011: Fixed issue reading in ELF files with naken430util (the file was being read in correctly, but the end address wasn't properly marked). Added an include file for msp430g2553 from Peter Johansson and an include file for msp430x14x from Alex B. September 21, 2011: Fixed issue with macros not unrolling in the lst files. Fixed issue with comments between .macro / .endm. Changed .db and .dw so it can have expressions instead of constants and labels. September 19, 2011: Changed db so it doesn't null terminate strings. Added .ascii and .asciiz for strings and null terminated strings. September 13, 2011: Some bug fixes: A typo in the assembler / disassembler mixed up adc and addc, the CG alias was missing from the assembler, and .w and .b couldn't be uppercase. ELF now splits up data and text sections (although there needs to be more work on that I think). September 5, 2011: I began adding support for ELF file output (and input into naken430util). It currently does something similar to what msp430-gcc does in that it dumps the binary block into a single .text section. This to me is kind of gross, so I'm going end up seeing what it takes to separate the binary block into multiple .text and .data sections (depending on if what is written in that location is a .db/.dw or instruction). I have a symbol table but it only has labels right now. I'm hoping to add other things later. I also plan on adding the DWARF support for debugging. The ELF option is configurable at compile time and since it currently adds about 4k of code to naken430asm. I believe some people are actually using naken430asm on embedded devices so I decided to make this optional. If ELF is not needed then a ./configure --disable-elf can remove the code. I still need to add a way to configure the ELF for which MSP430 device family the elf file is for. To see what symbols and sections are created in these ELF files, I have a program called magic_elf which can print out headers and such. I also changed the behavior of .db so that it won't warn and pad if the datasize is not 2 byte divisible. Instead it will warn and pad if an instruction or .dw falls on an unaligned boundary. Glen Worstell has contributed a makeInc.lua script that can take include files from TI's Code Composer and put it in a format the naken430asm can read. I included this script in the scripts dir of naken430asm. License naken430msp is distributed under the GPL license. How To Help Out Well, I'm not really looking for any patches right now since this is in heavily development and I prefer to do my own work, but the following would be really nice:
TODO
Assembling, Disassembling, Simulating
A program can be assembled from the command line with a simple: Simulation 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: Assembler Syntax
Like other MSP430 assemblers, naken430asm accepts C style #define, #ifdef,
#if defined(). An example would be: Assembler Directives
... To be completed ... Why?
Copyright 1997-2013 - Michael Kohn
|