[Inline assembler] Sequential `asm` blocks and return via EAX
James Miller
james at aatch.net
Thu Mar 8 02:04:16 PST 2012
On 8 March 2012 22:42, Denis Shelomovskij <verylonglogin.reg at gmail.com> wrote:
> 1. Is there any guaranties that no code will be added between sequential
> inline assembler blocks, e.g.:
> ---
> void f()
> {
> static if(x)
> asm { mov EBX, 3; }
> else
> asm { mov EBX, 7; }
>
> asm { mov EAX, EBX; } // Is EBX value defined here?
> }
> ---
> Is it documented?
>
>
> 2. Such question about return via EAX (is the following use
> legal/documented):
> ---
> int g()
> {
> asm { mov EAX, 4; }
> }
> ---
> Such use of `asm` to return a value is used here and there in
> http://dlang.org/iasm.html
For 1. I'd say that it would probably work, but you can't necessarily
rely on that, you may have to live with a bit of code duplication.
For 2. It seems that it should be fine, I can't check it right now,
but I would be surprised if it didn't compile and run.
--
James Miller
More information about the Digitalmars-d-learn
mailing list