|WP34S assembler/disassembler in the wild|
Message #1 Posted by Neil Hamilton (Ottawa) on 17 June 2011, 9:09 a.m.
Thanks to the good graces of the 3 amigos, an assembler/disassembler is now available for alpha testing.
It is written in Perl (5.8+) so that is a minimum requirement, and currently it is only a command line version.
It is available in the ./trunk/tools directory and is called "wp34s_asm.pl". You can get it through the "svn update".
Personally, I envisaged this tool as primarily an archiving and program concatenation tool but you can also write programs on a standard editor using the opcode format described in the output of one one Paul's programs (more on that later when I have had a chance to write documentation.)
It runs in both disassembly and assembly modes. In disassembler mode (triggered by the -dis switch) it writes its output to STDOUT so you will have to redirect the resulting listing to a file if you want to keep it. For example, to see what you had stored in flash-0, use the following:
$ ./trunk/tools/wp34s_asm.pl -dis wp34s-0.dat > myProg.wp34s
In assembly mode, you need to specify the output file because the output is a binary image (-o switch and *no* -dis switch):
$ ./trunk/tools/wp34s_asm.pl myProg.wp34s -o wp34s-0a.dat
These complimentary commands "should" result in the recreated flash image (wp34s-0a.dat) being identical to the original (wp34s-0.dat):
$ diff wp34s-0a.dat wp34s-0.dat
[Note that a few things could go "wrong" resulting in files that don't match but are otherwise functionally identical. More in the TBD documentation.]
I have tested it with the very small suite of WP34S programs I have at my disposal but it could really use some extra eyes and more sophisticated WP34S programs than my simple coding attempts.
There is a reasonable help screen that you can get by using the '-h' switch:
$ wp34s_asm.pl -h
As I said, it is very early in its development so it will undoubtedly have issues. Hopefully I'll find them before you do. :-) It will not currently eat the output from Paul's disassembler but that should be trivial to include in a day or two.
One really nice feature is that, once you have the programs in source form (what I am calling "*.wp34s"), the assembler can concatenate more than one program into a single flash image -- limited by the 506 word flash size limit. These source files may or may not have line numbers but they are ignored by the assembler in any case. For example:
$ wp34s_asm.pl gc.wp34s fp.wp34s moonlander.wp34s -o wp34s-3.dat
It was written to be platform independent but I have not been able to test it on an Apple yet.
I hope you find it useful! Let me know what dumb errors I have made (but be gentle!).