Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Gameboy Z80: How should RLCA and RRCA behave?

882 views
Skip to first unread message

Mateusz Viste

unread,
Aug 28, 2010, 8:15:42 AM8/28/10
to
Hi!

I'm working on a small project these days, trying to emulate a GameBoy's
Z80 CPU.
I have some doubts about the RLCA and RRCA instructions, and don't know
how they should be implemented exactly...

What I am wondering about, is what to do with flag Z?
The official Z80 manual says that flag Z should be left untouched (but
still... the GameBoy is not built on an "official" Z80).

In the document "GameBoy CPU manual v1.01" I see:
Z - Set if result is zero.

Hmm... Who should I believe?

Also, I tested the RRCA/RLCA behavior on the NO$GMB emulator (which
integrates a very nice debugger), and it's even more surprising:
Flag Z is set only when register A changes from a non-zero value to zero.
So if A is already 0, NO$GMB does'nt set Z after RRCA/RLCA.

Where could I find 100% sure information about that?

Best regards,
Mateusz Viste

Mateusz Viste

unread,
Aug 28, 2010, 9:26:02 AM8/28/10
to
On Saturday 28 August 2010 14:15, Mateusz Viste wrote:
> Also, I tested the RRCA/RLCA behavior on the NO$GMB emulator (which
> integrates a very nice debugger), and it's even more surprising:
> Flag Z is set only when register A changes from a non-zero value to
> zero. So if A is already 0, NO$GMB does'nt set Z after RRCA/RLCA.

Well, I wrote a bit too fast - there's no way a non-zero value become zero
after a RRCA/RRLA operation :-P
In fact, the NO$GMB emulator is *always* resetting Z flag after a
RRCA/RRLA operation (even if accumulator is zero).

Still, I have no clue about what should be the "correct" emulation of a
Z80-like GameBoy CPU...

Best regards,
Mateusz Viste

pgm

unread,
Sep 15, 2010, 11:26:45 AM9/15/10
to

In my opinion, the RRCA/RLCA instructions either behave as they do on
the real Z80 (I've seen no mention of modifications to these opcodes
anywhere) or they've been "adjusted" to act as the other RRC/RLC
instructions do. I vote for the former which means the H and N flags
(Ac and N in the Z80) are reset (set to 0) and the Z and C flags are
untouched.

Regards.

0 new messages