I'm building my own Z80 computer but I'm having a very strange problem. Consider this code:
That works as expected, outputting 0xaa on port 0x00. Now consider this code:
This outputs exactly 87 times to port 0x00, then it crashes. I took a look at the buses to see what's happening and it seems that it accesses incrementally addresses on memory when it's not needed. I read a year ago that this was a thing due to Z80's architecture, but the problem happens when this incremental access reaches 10000000(bin). This is what I see in the logic analyser:
The increment is happening on address 3 4 5 6 7 and 8, and when the 8th modulates, iorq stops and the CPU does weird stuff. Can any one please help?
I found the answer but if you have the same or similar issue, you should definitely read Spektre's and tofro's answers because they list a lot of very possible problems that could cause this.