Its done in programming.? I do not mean in BASIC.
?
Preserving the CPU state means writing all of the registers, internal? flags,
and interrupt status, to protected ram.? Fairly easy but the on startup
(aka reset) the first code in rom has to restore all that and then continue
where the CPU was stopped on power down.? That also means the state
of hardware like serial IO.? So power down is not something to be
allowed to happen randomly and power must be maintained for some
amount of time to permit the needed programming to complete.
?
However all this interacts with the design of hardware so if power down?
happens at a random point then saving all that before the power is
collapsed completely is problematic.
?
This takes a fair amount of understanding how Z80 works and how
the circuitry around? it has to work to support it.? Generally the z80MC is
not going to make all that easy for you.? It would add features not
planned for or typically expected.? that and the built in code in rom
would have to change.
?
So the best you can hope for is that ram only holds the program and?
basic will allow you to access it on startup (many can do that).? In that
case your treating memory during power down as a rom.
?
Also you unclear on what you wish to accomplish and the question
is not clear.? ? It also suggests working with hardware ie: ram, Eprom,
and IO chips is new and unfamiliar.? My early (1970s) experience was
opposite of that I had to build hardware, understand how that
works and then write code in assembler as little to none was
available (no Basic!).? ?That lead to the need to understand the
interaction of code and hardware.? ?Programming? on the bare metal.
People? brought up with PCs rarely, if ever, do that.
?
I hope this helps to answer your question. Or ask more questions.
?
Allison