
Known inline assembler bugs in Delphi 2

You should be aware of them since this could save you the hours I spent
finding out that they're actually compiler bugs!


1. Immediate address operands

address operands of the form

    [reg32 {+reg32*X} +imm32]

will be assembled incorrectly under certain circumstances. In short: If the
low word of imm32 is zero, the high word may be ignored too in some cases.

Unfortunately, we would like to write something like "mov gs:[edx+0a0000h],al"
to get a pixel plotted or so... Don't! Do it in a different way!


2. 16 bit operands

Usual way to get the environment selector is to say something like:

mov	ah,62h
int	21h         { get psp selector }
mov	es,ebx
mov	es,es:[2ch] { get environment selector }

The last instruction will be assembled incorrectly, it seems like the inline
assembler outputs only a 16 bit address operand ( 002C ) but generates an
instruction that expects a 32 bit operand AFAIR, meaning it forgets about
adding an address size prefix.


Workaraound:

...

mov	ah,62h
int	21h
mov	es,ebx
mov	ebx,2ch
mov	es,es:[ebx]


Feel free to inform me if you discovered more inline assembler bugs.
