Help with INC L instruction on my emulator vs openMSX

By fcoury

Rookie (18)

fcoury's picture

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:
https://www.dropbox.com/s/0iqyo9bbh8koovf/INC%20L%20-%20Z%20...

Thank you very much!

Login or register to post comments

By fcoury

Rookie (18)

fcoury's picture

29-03-2023, 01:38

Nevermind, this is the expected behavior duh!

By santiontanon

Paragon (1805)

santiontanon's picture

29-03-2023, 18:20

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

By TomH

Champion (364)

TomH's picture

29-03-2023, 18:48

In terms of testing a Z80 in isolation, I can recommend this suite; as the readme.md 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.