# HP Calculator Wiki

### Site Tools

41cl:replacement_cpu_board:saving_state2flash

# Sample routines for saving calculator state to FLASH

Sequence of steps to create the write from 800 to XXX (XXX is your choice of user FLASH ram this example uses 0C9). Check with the manual for available addresses, and for why YFNS should be in RAM when writing to FLASH.
Note that the production version of the 41CL loads the 'YFNZ' version of the Y functions ROM, which uses module ID 15, at page 7 when the MMU is disabled, such as for instance after a MEMORY LOST. The production documentation also uses the same version of the ROM in its example code for initializing the 41CL. (i.e. 'YFNZ' PLUG1L MMUEN.) Code written with functions from this ROM will fail if the 'YFNS' version is loaded instead.

LBL “YCTOF”
TURBO50
"062>812"
YMCPY
“812-RAM”               >>YFNS in RAM so YFWR and YFERASE can be used.
PLUG1L
“OC9000”
YFERASE
“800>0C9
YFWR
“YFNS”
PLUG1L
END


Now at a complete “MEMORY LOSS” state. MANUALLY execute the following, as any routine will be erased at line 7 and will not complete! I have been advised that a physical ROM plugged into the 41C with a routine based on the keystrokes below would indeed run uninterrupted, thus automating the restoration process also. Angel Martin has created a ROM of utilities which automate the backup and restore routines listed below. Thanks Angel!

MMUCLR                  >>basic reboot steps to enable MMU etc.
“YFNS”
PLUG1L
MMUEN
TURBO50
“0C9>800”               >>copy calc state from FLASH back to 800
YMCPY
XEQ “U-PG”              >>optional; see below
XEQ “SGMT”              >>optional; see below


Routine adaptable to any configuration desired: Unplug and PLug

LBL “U-PG”
SF 01
XEQ 61
“FUN WORK UPG”          >>these can be any titles or letters, just use the first letter
AVIEW                   >>of each mnemonic for the GETKEY function, in this example F, W, U
GETKEY
GTO IND X
LBL 21                  >>GETKEY “F”
“FUNS”
PLUG3
“TREK”
PLUG1U
GTO 10
LBL 63                  >>GETKEY “W”
CCDX
PLUG1U
“PPCM”
PLUG2
GTO 10
LBL 61                  >>GETKEY “U”
UPLUG1U
UPLUG2
UPLUG3
UPLUG4
FS?C 01
RTN
LBL 10
“DONE”                  >>I place the “DONE” here as the routine is so fast you
AVIEW                   >>will not know it has completed.
RTN


Clock set, after restoring calculator back to desired state, following “MEMORY LOSS”

LBL “SGMT”
TURBO50
“DATE?”
PROMPT
SETDATE
“TIME”
PROMPT
SETIME
“+-GMT?”
PROMPT
T+X
CLOCK
END


Provided by: Geoff Quickfall