All the program has to do is repeatedly get the current mouse position and set the pixel there, and that's all it does. These two links should help make sense of it:
The main loop contains an implicit state-machine that does multiple things on different iterations, which is partly responsible for the small size.
Another thing that you can clearly see is how efficient it is at using the registers; this is one area where compiler-generated code is consistently behind, and something I wish compilers would get better at --- an HLL could take as many bytes as this entire program just to put the parameters onto the stack and call a function.
Finally, one small correction:
ret ; assume [[FFEE]] = [0] = CD20 = int 20
...should be "assume [FFFE] = 0", because that's where the stack pointer is initially, and this program does not use the stack itself for its entirety --- it doesn't need to!
The loop instruction decrements CX, and then jumps if it is nonzero. Otherwise it "falls through". At that point CX contains the X coordinate of the cursor. Hence the comment:
Ah, I had zoomed in to see the code and completely disregarded the comments; in hindsight, I see that was a mistake. Although, I guess I should have guessed that cx could contain 0 in it.
http://stanislavs.org/helppc/int_33.html
http://stanislavs.org/helppc/int_10.html
The main loop contains an implicit state-machine that does multiple things on different iterations, which is partly responsible for the small size.
Another thing that you can clearly see is how efficient it is at using the registers; this is one area where compiler-generated code is consistently behind, and something I wish compilers would get better at --- an HLL could take as many bytes as this entire program just to put the parameters onto the stack and call a function.
Finally, one small correction:
...should be "assume [FFFE] = 0", because that's where the stack pointer is initially, and this program does not use the stack itself for its entirety --- it doesn't need to!