Re:Paint16b: A 16 byte paint program written in 12 lines
by boomlinde on Monday November 19, 2018 @09:08AM
(#18486467)
The value of BX is however strictly undefined, but practically always 0. Potentially some DOS will load this register with a different value, but probably no version of MS-DOS.
Re:Paint16b: A 16 byte paint program written in 12 lines
by freefal on Monday November 19, 2018 @10:50AM
(#18487209)
But why not explicitly set the register to 1 rather than assume its 0 and increment it by 1?
Re:Paint16b: A 16 byte paint program written in 12 lines
by amenghra on Monday November 19, 2018 @11:35AM
(#18487557)
On x86, some instructions are longer than others. Incrementing is a single byte. Setting the value 1 if you don’t assume anything is going to be 2 bytes (al, ah, bl, etc.) or 4 bytes for (ax, bx, etc.)
This online x86/x64 assembler is great: https://defuse.ca/online-x86-assembler.htm
Re:Paint16b: A 16 byte paint program written in 12 lines
by boomlinde on Monday November 19, 2018 @11:35AM
(#18487552)
Saves one byte, I assume. Register targets are typically encoded in the opcode while direct values follow the opcode byte.
Re:Paint16b: A 16 byte paint program written in 12 lines
by kevinmhickey on Monday November 19, 2018 @11:39AM
(#18487575)
Probably because (IIRC) mov is 2 bytes and inc is only 1 byte and they're optimizing for minimum size.
Edit: I take that back. According to [1]:
[0] https://thestarman.pcministry.com/asm/debug/debug.htm#INIT[1] http://www.delorie.com/djgpp/doc/rbinter/id/51/29.html