spjewkes / jrnz

A work-in-progress ZX Spectrum emulator
MIT License
1 stars 0 forks source link

Problem with ZX Spectrum ROM #28

Closed spjewkes closed 5 years ago

spjewkes commented 5 years ago

Typing the following '10 RUN' crashes when the enter key is pressed. A break point at 0x335b seems to be around where the problem goes awry.

From what I can tell when we push HL on the stack it contains 0x0000 and not some address. I'm guessing this causes the ROM to reboot.

I also notice that before this the same location starts to jump into memory it shouldn't so there could well be two problem (this problem looks like it's pushing an address onto the stack in the wrong byte order)

spjewkes commented 5 years ago

Problem appeared to be related to the handling of the P and M conditionals for JP. The implementation was checking the add/subtract flag rather zero flag. Changing this prevents the code from going haywire and jumping into invalid regions of memory.