Hi Y'All,
Based on a spec mostly worked out by Pauli, we have cobbled together an interesting addition to the WP 34S assembler tool chain. This is an assembler preprocessor (PP) that currently has the following features:
- It releases the user from the scourge of having to write those darn BACK and SKIP instruction (no more counting!). Just use "JMP SomeLabel" in place of BACK, SKIP, and GTO. Let the tool figure it all out for you.
- You can now use 'soft' labels with any instruction that would take a numeric or single-letter label, such as "XEQ DoThisReallyCoolThing" rather than "XEQ 25" (what's up with that?). Obviously there is a matching symbolic label at the target end of this as well.
- You can now use double quoted strings directly in the source and the tools will figure out that "WP 34S rocks!" needs to get parsed into 4 triple [alpha]'xxx' and a single [alpha] X.*** (Note that there a still a few known bugs in this feature if you decide to use any characters that mean something to regex. Working on it...)
*** Note that this specific example will overrun the alpha window on the screen so perhaps it is not such a good one to try :->
There are at least 3 sample programs in the library as example source for this tool. They are all knockoffs of the originals, suitably modified to take advantage of most of the features above (there is no 'promotion' of JMP to GTO in the example set -- though if you are sharp you may be able to figure out how to force it to occur).
- vector_pp.wp34s
- WHO_pp.wp34s
- 8queens_pp.wp34s
There is a new Assembler document (WP34s_Assembler_Disassembler.pdf, v0.5) that describes much of this in pretty reasonable detail (see Section 8), but basically to assemble any program that has PP code you need to add a new command line switch (-pp):
$ wp34s_asm.pl -pp vectors_pp.wp34s 8queens_pp.wp34s WHO_pp.wp34s -o wp34s-4.dat
If you don't want to use the new features, just don't use the '-pp' switch. Everything should still work as it did before. However if you feed it PP source without the '-pp' switch...
There are definite restrictions for using this PP code format. The most important is:
- DON'T PUT YOUR OWN NUMERIC LABELS IN UNLESS THEY ARE FOR A SPECIFIC PURPOSE! Use the symbolic labels wherever you can. There are places where this 'rule' cannot be followed (indirect LBLs for example and those connected to hot-keys) and the tool will work with what you have but label re-use is NOT ALLOWED with this tool. However, in most cases, they are just not required anymore -- the tool will select and fill these in for you if and when they are required. You might even see some code compression if you are used to using LBLs willie-nillie.
After a run, intermediate information is available in a file called wp34s_pp.lst in the directory you ran from. This file has the post-processed source that was actually assembled. Use this file if you want to debug your program on a machine or the emulator. It will have fully resolved line numbers, etc. (At the moment it does not retain your original comments. Not crapping please! A 'fix' may be in the works but it is complicated.)
Note that this is currently ONLY available in Perl so if you are using the EXE version of the assembler, you may have to wait a wee bit.
Probably still more bugs in this so let me know. (For a 'simple' little idea for an extension Pauli just tossed out, the code for this feature set is larger than the whole damn original assembler! :-)
We hope you enjoy it!
Source:
LBL'Roc'
CL[alpha]
"WP 34S rocks!"
XEQ Rocks_View
RTNRocks_View:: [alpha]VIEW
PSE 08
RTN
Into:
$ wp34s_asm.pl -pp rocks_pp.wp34s -o wp34s-4.dat; cat wp34s_pp.lst
Yields:
// Source file(s): rocks_pp.wp34s,
// Source File(s): .__0.894647826747136.tmp
// Preprocessor revision: $Rev: $
001 /* */ LBL'Roc'
002 /* */ CL[alpha]
003 /* */ [alpha]'WP[space]' // "WP 34S rocks!"
004 /* */ [alpha]'34S'
005 /* */ [alpha]'[space]ro'
006 /* */ [alpha]'cks'
007 /* */ [alpha] !
008 /* */ XEQ 99 // XEQ Rocks_View
009 /* */ RTN
010 /* */ LBL 99
011 /* Rocks_View:: */ [alpha]VIEW
012 /* */ PSE 08
013 /* */ RTN
// %LBLs:
// Label Step
// 99 => 011
// Total of 1 elements
(...and before you tell me "That's wrong. LBL 99 is actually at step 010!", its 'effective' location is 011 for the purposes of this tool... :-)