Help with INC L instruction on my emulator vs openMSX

Par fcoury

Rookie (18)

Portrait de fcoury

29-03-2023, 01:26

Hey there friends, as an exercise of something I always wanted to do even since I was a kid, and now that work is very slow, I decided to work on my own MSX1 emulator from scratch written in Rust.

I am using openMSX as the validation for my code and I just stumbled across something that happens and I don't quite understand.

If you see the openMSX debugger window on the linked video, the PC is at 0x0370 and the opcode at this location is 0x2C (INC L). At this point the flag Z is set to 1 (Z) and the value for register L is 0x03.

When I step over this instruction, all of a sudden the Z becomes 0 (NZ) and I can't understand why. On my emulator Z remains 0 (NZ) and I can't quite understand what's happening.

Does anyone have more insight on what's happening here?

Here's a link to the video in question, hopefully it makes sense:

Thank you very much!

!login ou Inscrivez-vous pour poster

Par fcoury

Rookie (18)

Portrait de fcoury

29-03-2023, 01:38

Nevermind, this is the expected behavior duh!

Par santiontanon

Paragon (1832)

Portrait de santiontanon

29-03-2023, 18:20

hehe, indeed, that's expected. Are you writing a whole MSX1 emulator, or just the z80 part btw? Smile

Par TomH

Champion (375)

Portrait de TomH

29-03-2023, 18:48

In terms of testing a Z80 in isolation, I can recommend this suite; as the says it's 1,000 tests per opcode, each test being a start state and an end state before and after a single instruction execution, and including bus states. So it allows you to develop and test each and every opcode completely in isolation if you want — full test-driven development is an option.

I'm in the process of upgrading my MSX 1 emulator to also model the MSX 2, that's definitely proving to be a slog owing to lack of detailed VDP documentation. But hopefully I'm getting there.