gens-gs-ii icon indicating copy to clipboard operation
gens-gs-ii copied to clipboard

Z80 register initial values (Bugzilla #47)

Open GerbilSoft opened this issue 8 years ago • 0 comments

status IN_PROGRESS severity normal in component mdZ80 for --- Reported in version unspecified on platform All Assigned to: David Korth

On 2011-10-17 13:00:36 -0400, Javier Degirolmo wrote:

The initial values for the Z80 registers should be as follows:

AF: $FFFF BC: undefined DE: undefined HL: undefined IX: undefined IY: undefined PC: $0000 SP: $FFFF IFF1: clear IFF2: clear I: $00 R: $00

"Undefined" means that it could be anything. Some people suggest setting them to $FFFF, but I guess the proper way to emulate this would be by assigning them random values, since they're garbage.

I have no info on AF', BC', DE' and HL'. I guess the latter three are also undefined, but no idea about AF'. I guess that for now it'll be safer to leave that one as $FFFF, just in case.

Not emulating this properly prevents Echo from crashing in those horribly buggy builds I was having trouble fixing :/ (thanks to Eke for finding out the cause, by the way)

On 2011-10-17 13:02:07 -0400, Javier Degirolmo wrote:

Forgot to mention: the undefined registers are not modified when the Z80 is just reset (rather than being started up). Not sure if this is true for all Z80 models though (e.g. there may be some manufacturer-specific model that breaks this), so consider this unconfirmed for now.

On 2011-10-19 23:27:12 -0400, David Korth wrote:

I did some work on this in the make-vdp-non-static branch, but I'll need to write a test ROM and have someone verify the register values before I can close this bug.

commit SHA: 4f3e7ad7e2dee9244ccbe8eea0af9b2d2b408d99 Author: David Korth [email protected] Date: Wed Oct 19 23:14:55 2011 -0400

[mdZ80] mdZ80.c: Split hard-reset and soft-reset handling into separate functions.

The Z80 doesn't clear all registers when the !RESET line is asserted.
I'm not positive about certain registers like the regular data registers
and the shadow registers, but we have documentation for AF, PC, and SP.

I'll write an MD test program later to check the values of these registers
on !RESET so someone can test the actual hardware.

Updated libgens and gens-qt4 to handle the Z80 reset split.

GerbilSoft avatar Mar 30 '16 02:03 GerbilSoft