User Tools

Site Tools


sd:code_gremlins

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sd:code_gremlins [2026/01/29 01:43] – created - external edit 127.0.0.1sd:code_gremlins [2026/04/01 04:17] (current) appledog
Line 49: Line 49:
 //"What goes up must come down... eventually..." Aaand... it's GONE!// //"What goes up must come down... eventually..." Aaand... it's GONE!//
  
-There are two forms of this goblin. They look exactly the same except one of them has a beard and a red hat, while all the other goblins have white hats. These goblins are relentless, they are constantly trying to fuck with the stack.+There are two forms of this goblin. They look exactly the same except one of them has a beard and a red hat, while all the other goblins have white hats. These goblins are relentless, and they are constantly trying to fuck with the stack.
  
 The first one looks for functions with unbalanced PUSH/POP. Returns to address $292929. Endless calls to LDA #0000. Corrupts everything in its wake. The first one looks for functions with unbalanced PUSH/POP. Returns to address $292929. Endless calls to LDA #0000. Corrupts everything in its wake.
Line 70: Line 70:
  
 Weakness: His true name. You must call him by his true name: The carry gremlin. Call him by his name and, his true form revealed, he will disappear in a puff of smoke. Weakness: His true name. You must call him by his true name: The carry gremlin. Call him by his name and, his true form revealed, he will disappear in a puff of smoke.
 +
 +=== Zero gremlins
 +This is really a goblin, but it is wearing a mask. Remove the mask and you see.. a goblin! Hes gobblin your CPU time. But wait.. he's wearing another mask! Remove the mask and what do you find?
 +
 +    NOP
 +
 +Great scott! We're being invaded by NOPs!
 +
 +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, they are wearing masks, you must thoroughly investigate each case.
 +
 +    [^;]CMP [A-Za-z]+,\s*[#$]?0\b
 +
 +or maybe
 +
 +    ^\s+(LD|ADD|SUB|AND|OR|XOR|SHR|SHL|INC|DEC|MOV)\w*.*\n\s+CMP\s+[A-Za-z]+,\s*[#$]?0\b\n\s+JZ
 +
 +Surefire cases look like this:
 +
 +    LDA [$C000]
 +    CMP A, #0
 +    JZ @label
 +
 +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.1769650981.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki