by leanchess · 6y ago · 0 comments
Indeed, the very first instruction is
int 10h ;BIOS display mode 0
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
mov cl, 8
instead of mov cx, 8The 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.