Re: Newest Wp34s ROM and backwards compatibility Message #19 Posted by Neil Hamilton (Ottawa) on 14 June 2011, 10:22 p.m., in response to message #18 by Paul Dale
Quote:
Those duplicates are intentional.
That is fine. I am presuming that the calculator doesn't care which version of the opcode it sees then. Once the binary is converted to a mnemonic form, it loses connection to the original opcode. (Is there a reason you can share/recall as to why just these 2 are repeated?)
I have a first crack of the assembler/disassembler up and running. In disassembler mode it reads the flash image and converts it to a text form very similar to the right hand side of the legal opcode table. There are a very few differences (such as the conversion factors being embedded in the opcode table) that have to be dealt with as exceptions but generally it is pretty faithful.
In assembler mode it is capable of taking in multiple mnemonic sources and seamlessly stitching them together into a single binary image. It recalculates and injects the CRC16 so no MAGIC_MARKER's are required.
I am not exactly sure how to load a single flash (ie: wp34s-0.dat) into the emulator so I did a seocnd little stop-gap script to overlay it on top of the emulator 'wp34s.dat' file which loads automatically. This works for now but I will experiment more with the actual H/W when I have some time. I am sure it is easy to do.
(Most) Everything seems to have worked beautifully except my program for calculating Great Circle routes now converts from nmi->AU instead of nmi->km! My legal opcode table came from 1104 and I am now running on emulator 1109 so I am thinking something may have changed between them -- something to do with stones and kg perhaps? (I haven't rebuilt a table as yet since that means moving back over to Windows -- ugh!).
Currently the script is parsing the legal opcode table to generate that hash table so I either need an external file (ugly solution) or I embed the table in the Perl script (cleaner solution but HUGE). Typically, I have split the difference and have both modes in the script. That has the advantage of allowing older flash images to be translated to the new opcodes by giving it an optional older legal opcode table.
Since there is a lot of repetition in the table (ie: SL 01, SL 02, ... SL 09, etc), I am thinking I can compress it with a bit of cleverness to get the script to a much smaller state.
I have tested it with a few programs I have written and a transcription of a program Jake Schwartz wrote: "wp34S IEEE Floating-Point Conversions". I have concatenated these with the tool in various orders and all seems well (except for astronomical units, of course :-)
I am not sure if anyone would be interested in trying an alpha of this Perl script or not. If so let me know and I will get it to you. There are certainly still things I need to test that will undoubtedly break (I have never done much with the alpha stuff as yet, for example).
Below is a fragment of the Jake's Floating Point program as I transcribed it from his note (mistakes are mine! hard to copy from 3 JPG images). I have added a few comments to help me keep things straight. These are ignored by the assembler. Also, the line numbers are ignored so you can easily concatenate several sources together into a single image (see below).
# From Jake Schwartz 7-June-2011 (near: http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/forum.cgi?read=185649#185649)
#
# Hand entered from 3 JPG's(!?) and converted to the opcode style shown in the legal opcode
# dump from the console app so there may be a mistyping or two.
#
# Keep the leading asterisk in front of the LBL's since that is a an easy marker to see and
# is easy to "clean up" in the assembler.
#
001 *LBL B
002 BASE 16
003 2COMPL
004 WSIZE 32
005 SL 01
006 ENTER[^]
007 ENTER[^]
008 x=0?
009 GTO 02
010 MASKR 24
011 AND
012 XOR
013 RCL L
014 x[<->]y
015 MASKL 08
016 x=? Y
017 GTO 04
018 R[v]
019 x=0?
020 GTO 03
Here is the above source fragment being assembled and the resulting output image dumped as hex:
$ wp34s_asm.pl fp.wp34s -o fp.dat; hexdump fp.dat
0000000 c782 00ab bb65 e410 0154 d520 da01 0000
0000010 0000 0017 be02 e318 0317 0319 8b6c 0107
0000020 e208 aa65 be04 0109 0017 be03 0107 dd18
0000030 bb01 cd66 0003 0107 d608 000e 000c 0302
0000040 cb66 bb02 0158 020f 0303 0002 0006 0005
0000050 0005 ae65 be0b 0107 013a bb0b 0002 000d
0000060 000d 0302 ca65 ca66 013a bb03 dd18 0107
0000070 be01 bb04 0109 0001 ab65 be05 0006 0009
0000080 000a 0000 bb05 0107 cd66 0003 dc01 0107
0000090 ca66 be02 bb64 001a ca01 001a 0003 0154
00000a0 0000 0017 0000 0017 be0d 020e 0008 0007
00000b0 0107 0302 0204 001c be0a 0006 0302 bb0a
00000c0 0000 020f 010a 0107 010a 0303 cf01 0003
00000d0 010a 0003 bb0d d538 e410 cb66 cb65 aa65
00000e0 013a 000e 0012 0301 0107 cb00 001a ca00
00000f0 0205 0107 001a be63 0006 0301 bb06 8463
0000100 0109 d520 000d 0005 0301 e218 0317 ce66
0000110 b863 da01 8b63 0014 0014 af65 be07 0107
0000120 0109 0109 0001 010a 010a ca65 bb07 0109
0000130 0318 cd00 dd08 d709 cb66 013a bb09 0205
0000140 0008 0005 ae65 0107 0109 0005 dde5 0107
0000150 0109 0304 0005 be06 8303 8303 8303 8303
0000160 8303 8303 8303 8303 8303 8303 8303 8303
*
00003f0 8303 8303 8303 8303 0000 0000 0000 0000
0000400
To close the loop, a fragment of disassembly of this resultant flash-compatible image:
$ wp34s_asm.pl -dis fp.dat | head -20
001 LBL B
002 BASE 16
003 2COMPL
004 WSIZE 32
005 SL 01
006 ENTER[^]
007 ENTER[^]
008 x=0?
009 GTO 02
010 MASKR 24
011 AND
012 XOR
013 RCL L
014 x[<->]y
015 MASKL 08
016 x=? Y
017 GTO 04
018 R[v]
019 x=0?
020 GTO 03
To stitch multiple source together is simply a matter of giving it more than one source. I haven't tested the 506 opcode limit yet but it should correctly crap out if this is exceeded.
$ wp34s_asm.pl fp.wp34s gc.wp34s -o fp_gc.dat
I still have a few things I want to do (detect duplicate labels, maybe allow an alternate [more friendly] mnemonic format, etc.) but I hope someone might find this useful. [Warning until I can compress the opcode table, the script is *BIG* at 465K!]
If people are interested, and I can be coached on how to do it, maybe it can be uploaded to a public site in due course.
Cheers...
|