Re:Paint16b: A 16 byte paint program written in 12 lines
by chris_overseas on Monday November 19, 2018 @06:09AM
(#18485565)
No, AFAIK MS-DOS always initialises it to zero before starting the program. I'm trying to find a better reference, but I think this[0] effectively explains what state the registers are in on entry to your program.
Edit: I take that back. According to [1]:
.COM-format executables begin running with the following register values:
AL = 00h if first FCB has valid drive letter, FFh if not
AH = 00h if second FCB has valid drive letter, FFh if not
[0] https://thestarman.pcministry.com/asm/debug/debug.htm#INIT
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.
Hmm. So the second time this program is run, it will fail?