Well, since the z80 has a von Neumann architecture, we can write directly over the code we are running on the fly.
We can open this can of worms for some significant performance improvements. But I can't think of any right now, probably because my knowledge of z80 is pretty close to nonexistent.
I do have one in mind right now, actually. Maybe. Suppose we have a piece of code which is supposed to write something into memory or push a register into the stack which will influence the outcome of a branch later on. But instead of doing this, we can just write directly on the memory address that represents the branch and has the relevant instruction to jump. This way, the CPU is spared from having to perform a comparison later on, simply by immediately giving the branch a predetermined outcome unless changed later on.
This is why I lose time thinking about z80 code and never end up learning anything or getting anything done. I just overthink it. I think about insane ways to optimize my code, which are hard to get to work since a tiny change or addition can throw everything off. I need to stop reading about the black magic in the restricted section and think about real, unoptimized, practical working z80.
We can open this can of worms for some significant performance improvements. But I can't think of any right now, probably because my knowledge of z80 is pretty close to nonexistent.
I do have one in mind right now, actually. Maybe. Suppose we have a piece of code which is supposed to write something into memory or push a register into the stack which will influence the outcome of a branch later on. But instead of doing this, we can just write directly on the memory address that represents the branch and has the relevant instruction to jump. This way, the CPU is spared from having to perform a comparison later on, simply by immediately giving the branch a predetermined outcome unless changed later on.
This is why I lose time thinking about z80 code and never end up learning anything or getting anything done. I just overthink it. I think about insane ways to optimize my code, which are hard to get to work since a tiny change or addition can throw everything off. I need to stop reading about the black magic in the restricted section and think about real, unoptimized, practical working z80.