sd:code_gremlins
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| sd:code_gremlins [2026/04/01 03:12] – appledog | sd:code_gremlins [2026/04/01 04:17] (current) – appledog | ||
|---|---|---|---|
| Line 80: | Line 80: | ||
| To get rid of this Goblin, remember which ops set cpu flags. Before you flagrantly issue a CMP against zero, ask yourself; is it already set? | To get rid of this Goblin, remember which ops set cpu flags. Before you flagrantly issue a CMP against zero, ask yourself; is it already set? | ||
| - | Here is the magic scroll to find and eradicate these gremlins; but beware, | + | Here is the magic scroll to find and eradicate these gremlins; but beware, |
| [^;]CMP [A-Za-z]+, | [^;]CMP [A-Za-z]+, | ||
| + | |||
| + | or maybe | ||
| + | |||
| + | ^\s+(LD|ADD|SUB|AND|OR|XOR|SHR|SHL|INC|DEC|MOV)\w*.*\n\s+CMP\s+[A-Za-z]+, | ||
| Surefire cases look like this: | Surefire cases look like this: | ||
| Line 90: | Line 94: | ||
| JZ @label | JZ @label | ||
| - | Here, the CMP is always redundant as LD sets Z. Other common ops that set Z; ST, AND, DIV... | + | Here, the CMP is always redundant as LD sets Z. Other common ops that set Z; ST, AND, DIV, MOV, INC, DEC... |
| + | |||
| + | === Zero gremlins II: The Revenge | ||
| + | The Zero gremlin never really went away, he just changed masks. | ||
| + | |||
| + | ^\s+(LD|ST)\w+.*\n\s+(INC|DEC)\s+ | ||
| + | ^\s+(INC|DEC)\s+.*\n\s+(LD|ST)\w+ | ||
| + | |||
| + | The above will unmask these goblins right away! | ||
| == History | == History | ||
sd/code_gremlins.1775013122.txt.gz · Last modified: by appledog
