By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

c++ & inline asm

P: n/a
Hello
I have a simple question about inline asm.
suppose I have asm { push eax, 123 }
does it mean that it will have exactly this effect as in usual asm or
it's just a suggestion to the compiler (meaning that the compiled
program might probably use some other register in place of eax)

Thanks.

Ps. I do not have any intention to use inline asm.
Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
__PPS__ wrote:
I have a simple question about inline asm.
suppose I have asm { push eax, 123 }
Actually, you're supposed to have

asm ( "push eax, 123" ) ;

(IOW, inside the parentheses there should be a string literal),
according to the Standard, subclause 7.4. Any other form, like

asm { <actual assembly commands> }

is probably an extension provided by the compiler.
does it mean that it will have exactly this effect as in usual asm or
it's just a suggestion to the compiler (meaning that the compiled
program might probably use some other register in place of eax)
The meaning of the asm definition is implementation-defined. The
usual purpose is to convey something to the assembler, often insert
a short piece of assembly code into the function. And, yes, usually
the code is assembled *exactly* as written.
Thanks.

Ps. I do not have any intention to use inline asm.


LOL... Why the question, then?

V
Jul 23 '05 #2

P: n/a
> > Thanks.

Ps. I do not have any intention to use inline asm.


LOL... Why the question, then?


Victor, it's because my good friend Artur says that asm is more
`powerful` when it comes to precise control of which register should be
used etc etc. He says that asm( "whatever") blocks only give compiler a
tip but aren't for sure included as-is (similar to inline keyword)

Thanks

Jul 23 '05 #3

P: n/a
pa**********@gmail.com wrote:
Victor, it's because my good friend Artur says that asm is more
`powerful` when it comes to precise control of which register should be
used etc etc. He says that asm( "whatever") blocks only give compiler a
tip but aren't for sure included as-is (similar to inline keyword)

The standard says:

"7.4 The asm declaration

An asm declaration has the form

asm-definition:
asm ( string-literal ) ;

The meaning of an asm declaration is implementation-defined. [Note: Typically it is used
to pass information through the implementation to an assembler. ]"
So its behaviour is implementation-defined. However in most compilers it is used to pass
instructions directly to the assembler. In other words, in most compilers the passed
instructions are used, and are not considered a suggestion.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #4

P: n/a

"__PPS__" <bl******@mail.ru> wrote in message
news:72**************************@posting.google.c om...
I have a simple question about inline asm.
suppose I have asm { push eax, 123 }
does it mean that it will have exactly this effect as in usual asm or
it's just a suggestion to the compiler (meaning that the compiled
program might probably use some other register in place of eax)


Compilers that implement an inline assembler usually implement it as exactly
the instructions listed. After all, that's the whole point of having one.

-Walter
www.digitalmars.com/ctg/ctgInlineAsm.html C++ inline assembler
www.digitalmars.com/d/iasm.html D inline assembler
Jul 23 '05 #5

P: n/a
Thanks for the info, now I'm sure about this topic :)

Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.