diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-03-10 12:04:46 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-03-10 12:04:46 -0400 |
commit | 0521aafc20aa1fd8f043d35861e7bb1dc3a68818 (patch) | |
tree | 662cbc9ba392ae98391dfe4708c26f4cb7d5931f /Optimizing-assembly-code.md | |
parent | 7d595a53ce0dcc049910ac9011a37050dfedb2e5 (diff) |
Optimization advice
Diffstat (limited to 'Optimizing-assembly-code.md')
-rw-r--r-- | Optimizing-assembly-code.md | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md index 325798a..4e84545 100644 --- a/Optimizing-assembly-code.md +++ b/Optimizing-assembly-code.md @@ -2,6 +2,16 @@ Sometimes the simplest way to write something in assembly code isn't the best. A Most of these tricks come from either [Jeff's GB Assembly Code Tips v1.0](http://www.devrs.com/gb/files/asmtips.txt), or [WikiTI's Z80 Optimization page](http://wikiti.brandonw.net/index.php?title=Z80_Optimization). (Note that Z80 assembly is *not* the same as GBZ80; it has more registers and some different instructions.) +WikiTI's advice fully applies here: + +> Note that the following tricks act much like a [peephole optimizer](https://en.wikipedia.org/wiki/Peephole_optimization) and are the last optimization step: remember to first optimize your algorithm and register allocation before applying any of the following if you really want the fastest speed and the smallest code. +> +> Also note that nearly every trick turns the code less understandable and documenting them is a good idea. You can easily forgot after a while without reading parts of the code. +> +> Be warned that some tricks are not exactly equivalent to the normal way and may have exceptions on their use; comments warn about them. Some tricks apply to other cases, but again you have to be careful. +> +> There are some tricks that are nothing more than the correct use of the available instructions on the Z80. Keeping an [instruction set summary](https://rednex.github.io/rgbds/gbz80.7.html) helps to visualize what you can do during coding. + ## Contents |