The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

35s filesystem
Message #1 Posted by Andrew Nikitin on 4 Oct 2008, 5:12 p.m.

I would like to continue on the topic of saving state in indexed registers.

Each program has specific set of registers it uses (or cares about). When using calculator to run a different program these registers may be partially overwritten. Or, maybe the same program need to be run with slightly different set of input data and it is a hassle to switch beween them.

The idea is to use bitmask to specify which registers need to be saved and save them in the continuous stretch of index registers. Each used register corresponds to 1 in a binary number, A being least significant bit. For example if program uses registers A,B,C,D,E, R, T, X then the mask is 08a001fh = 9043999. Together with 3 digit origin mask forms "filde descriptor". In this case possible "file descriptors" are 9043999000, 9043999008, 9043999016 The registers usage mask may be declared in program description or even be present somwhere in the program itself.

The program below is actually 3 programs under one roof to view, read and write working registers into indexed registers according to file descriptor.

fd XEQ J002 -- will view contents of a file fd XEQ J003 -- will load working registers from indexed registers fd XEQ J004 -- will save working registers into indexed registers

The load and save programs use "I" register so they cannot save/restore it -- I would appreciate any ideas on how to do this without too much hassle.

View program J002 also uses M register -- I believe it is ok in that specific case, but it would be much better if it did not.

I also would like to include a feature of saving a state, inclding stack and program counter -- to be able to interrupt long running program and return to it later.

The program is pretty straightforward -- it cycles through the set bits of a mask and for each set bit it increments I and saves content of a corresponding register to (I).

(Internal routine J005 separates mask from index origin and J014 calculates negative register index corresponding to the next set bit in a mask)

J001 LBL J     J018 -         J035 RTN       J052 x=0?      J069 RTN
J002 GTO J031  J019 AND       J036 XEQ J014  J053 RTN       J070 XEQ J014
J003 GTO J051  J020 XOR       J037 Rv        J054 XEQ J014  J071 x<> I
J004 GTO J067  J021 ENTER     J038 XOR       J055 RCL (I)   J072 RCL (I)
J005 ENTER     J022 LOG       J039 STO M     J056 x<>y      J073 x<>y
J006 ENTER     J023 2         J040 Rv        J057 x<> I     J074 x<> I
J007 1000      J024 LOG       J041 Rv        J058 x<>y      J075 Rv
J008 RMDR      J025 /         J042 RCL I     J059 STO (I)   J076 STO (I)
J009 STO I     J026 1.1       J043 1000      J060 CLx       J077 CLx
J010 x<>y      J027 +         J044 /         J061 1         J078 1
J011 LASTx     J028 IP        J045 -         J062 +         J079 STO+ I
J012 INT/      J029 +/-       J046 RCL (I)   J063 STO I     J080 Rv
J013 RTN       J030 RTN       J047 STOP      J064 Rv        J081 XOR
J014 ENTER     J031 XEQ J005  J048 1         J065 XOR       J082 GTO J068
J015 ENTER     J032 STO M     J049 STO+ I    J066 GTO J052
J016 ENTER     J033 RCL M     J050 GTO J033  J067 XEQ J005
J017 1         J034 x=0?      J051 XEQ J005  J068 x=0?


[ Return to Index | Top of Index ]

Go back to the main exhibit hall