Skip to content

Comment on LeanChess: The smallest chess-playing program at 328 bytesparent

Comments

Yup, I actually got to the end of reading the code and noticed you do things like that. You have to read slowly to get all the nuances, so it was totally worth the effort.

The weirdest DOS "shortcut" I ever did was to remap INT 21h onto INT 3, giving me a single-byte INT 21h with a debug-killing side effect. Of course you have to have enough INT 21h's to convert to make that worthwhile, but it is a neat trick to have about if you have a lot of the same INT repeated throughout.

    sub     ax,ax
    mov     ds,ax
    mov     es,ax
    mov     si,21h*4
    mov     di,3*4
    movsw
    movsw
Of course if you aim it just right, you don't need the sub ax,ax. For that matter, it's an ideal place to use cx if you just exited a loop. And even then, you could probably find other short methods to make similar change. You don't even need to cli/sti because the chances of an INT 3 happening in the middle of the change is of no consequence, and all your INT 3 calls will only happen after this part runs.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.