; HP 41C (and subset on HP 11C or HP 15C) RPN Hex to/from Dec converters ; author Neil Franklin, last modification 2010.09.11 ; works on 11C, after dropping all global label and GTO .. and ASN stuff ; surely also works on 15C (it is a direct superset upgrade to 11C) ; most likey impossible on 10C or 12C (needs no labels and no R^ and no GSB) ; use prog steps for labels, 3 Rv for R^, but what for GSB? ; senseless on 16C (has built in Hex and Dec conversion, and much more) ; senseless on 32S and 32SII and 42S (have built in Hex and Dec conversion) ; likely on 65 and 67 (but not tested) ; likely on 34C (must rename labels C and D to numeric) ; likely on 29C (must rename all labels and must use Rv Rv Rv for R^) ; unlikely on 33E/33C (no labels and no R^ and space not enough) ; impossible on 55 and 25/25C and 38E/38C (same as 10C and 12C, GSB) ; standard keyboard stuff, always present in my 41C system configuration ; we need these a lot, even if just temporary ASNs, while entering program ; ignore this stuff on an HP 11C/15C, as no such features present or needed ASN R^ % ; because this is shift Rv ASN INT P->R ; because these are 2 related functions ASN FRC R->P USER ON ; activate all the assignments ; standard program stuff, always present in my 41C system configuration ; 42S style would call this TOP.FCN, 41C does not allow . in names ; ignore this stuff on an HP 11C/15C, as no such features present PRGM LBL KEYS ; only 41C, unselect any program for A..J,a..e GTO .. ; is also END, no RTN needed here, save space PRGM ASN KEYS shift - ; get rid of effects of other programs ; so we can leave USER mode on all the time ; select program stuff, works together with above standard program stuff ; ignore this stuff on an HP 11C/15C, as no such features present PRGM LBL HEXDEC ; only 41C, select program for A..J,a..e keys RTN ; appart from that do nothing PRGM ASN HEXDEC shift + ; shift + for HEXDEC/on, shift - for KEYS/off ; 16bit basic stuff ; Hex with 4 digits nn = 00..15, entered as aabbccdd ; from here on is needed for all versions, 41C or 11C/15C ; uses no registers PRGM LBL A ; Hex2Dec INT 1E8 / FRAC ; chop to 4digit*4bit=16bit range 0 x<>y ; start Dec GSB 1 GSB 1 GSB 1 ; split off and add first 3 Hex digits 100 * + ; add last digit RTN LBL 1 ; for GSB, split off Hex and add to Dec 100 * ENTER ; shift by Hex digit FRAC Rv ; rest of data, hide INT + 16 * ; get and add and shift this digit R^ ; unhide for rest RTN LBL B ; Dec2Hex INT 65536 / FRAC ; chop to 16bit range 0 x<>y ; start Hex GSB 2 GSB 2 GSB 2 ; split off and add first 3 Hex digits 16 * + ; add last digit RTN LBL 2 ; for GSB, split off Dec and add to Hex 16 * ENTER ; shift by Hex value FRAC Rv ; rest of data, hide INT + 100 * ; get and add and shift this digit R^ ; unhide for rest RTN PRGM ; 32bit extended stuff ; merge/unmerge 2 short 16bit <-> 1 long 32bit, high/Y then low/X ; from here on can be dropped for saving space ; uses no registers PRGM LBL C ; ShortHShortL2Long x<>y ; get first entered high part 65536 * ; shift by 16bit left + ; add up RTN LBL D ; Long2ShortHShortL 65536 / ; shift by 16bit right ENTER INT ; split off high part x<>y FRAC 65536 * ; shift low part back left INT ; drop rounding errors GTO .. ; is END, no RTN needed here, save space PRGM