As for CX, there aren't that many loops in LeanChess (precisely 5, but who's counting :)). However, CH being always 00h allows to save a couple more bytes by doing
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.
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.
Comments
Thanks.
Indeed, the very first instruction is
that relies on AX being 0.As for CX, there aren't that many loops in LeanChess (precisely 5, but who's counting :)). However, CH being always 00h allows to save a couple more bytes by doing
instead ofYup, 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.
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.