Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Z80 cycle count / pre-fetch thing

Reply to topic
Author Message
  • Joined: 05 Sep 2013
  • Posts: 2375
Reply with quote
Z80 cycle count / pre-fetch thing
Post Posted: Fri May 17, 2019 3:56 pm
I stumbled upon a few documents/webpages that address the Z80 pre-fetch feature and its effect on instruction cycle counting.
The point here is (it seems) that after a jump you'll have your pre-fetch queue empty and so the first operation might have a penalty, depending on the instruction itself.
For instance the CP (HL) instruction (expected) timing is 7 cycles but, since you need one memory access fetch the byte opcode and a second memory access to read memory pointed by HL, and since each access requires 4 cycles, you'd end up with an additional cycle taken.
An instruction like ADD HL,BC instead, being a single byte instruction that doesn't need any other memory access, it wouldn't ever take more than the expected 11 cycles.

Does that apply to Master System too?
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 12718
  • Location: London
Reply with quote
Post Posted: Fri May 17, 2019 7:56 pm
I guess so since it's a standard Z80 with no wait states. It would be interesting to confirm this, though.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 2375
Reply with quote
Post Posted: Sun May 19, 2019 10:47 am
it seems to me I can't simply use the Z80 R register to measure this, right? :/
  View user's profile Send private message Visit poster's website
  • Joined: 14 Aug 2000
  • Posts: 494
  • Location: Adelaide, Australia
Reply with quote
Z80 cycle count / pre-fetch thing
Post Posted: Sun May 19, 2019 11:35 am
You could use a loop and count the iteration between line interrupts.

The loop below is 23 cycles advertised, so if you set your line interrupt 10 lines apart, that's 2280 cycles, room for 99 iterations, you'll be able to see if there 99 non-prefetched memory accesses.

Loop:
INC (HL)
JR Loop
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!