Skip to main content

Timeline for How fast is memcpy on the Z80?

Current License: CC BY-SA 3.0

4 events
when toggle format what by license comment
Sep 17, 2017 at 1:09 comment added George Phillips I think the question was just poorly worded. Taking your interpretation it is a non-sequitur. You can't optimize a single instruction.
Sep 17, 2017 at 0:44 comment added Tommy @George your first paragraph shows that you've misunderstood the question. Directly to quote it: "I gather the fastest way to implement memcpy (copy a certain number of bytes from one place in memory to another) on the Z80 is to use an instruction called LDIR. But how fast is the result, when fully optimized, in terms of clock cycles per byte?" So it asks about optimising an LDIR implementation. It is correct to say that an LDIR implementation doesn't need optimising. It is then an extension to discuss alternatives, but I felt it helped more fully to answer "But how fast is the result?"
Sep 16, 2017 at 21:28 comment added Raffzahn George, you might want to add that above is only true for fixed adresses of src and dst (and dst being destination+14) and only works if only 14 bytes are to be transfered. With variable addresses LD SP,(x) counts 20 clocks (may be overcome with self modifying code but only in RAM) and any transer of more than 14 bytes adds an overhead of at least 61 cycles for pointer update plus 20 for the loop, for a total of 256 cycles, or ~18,3 cycles, thus beeing slower than an unroaled LDI
Sep 16, 2017 at 20:32 history answered George Phillips CC BY-SA 3.0