473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c++ & inline asm

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
5 2149
__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
> > 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
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

"__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
Thanks for the info, now I'm sure about this topic :)

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4765
by: David Morgan | last post by:
Hello I have been using the CDONTS.Newmail object for a number of years to send nicely formatted HTML Emails with inline images. I am now trying to switch over to using CDO and I cannot...
2
4256
by: qazmlp | last post by:
// test.h class test { public : inline void check() ; } ; // test.C inline void test::check() // Is 'inline' optional here?
3
8245
by: Victor Irzak | last post by:
Hello, I have an ABC. it supports: ostream & operator << I also have a derived class that supports this operator. How can I call operator << of the base class for derived object??? Is it...
0
2994
by: Anne van Kesteren | last post by:
Ok, here it goes. Originally I submitted this proposal to www-style. Since I don't get feedback there, I think I missed a few (maybe a lot) of points. Proposal:...
79
5186
by: pinkfloydhomer | last post by:
I want to scan a file byte for byte for occurences of the the four byte pattern 0x00000100. I've tried with this: # start import sys numChars = 0 startCode = 0 count = 0
27
3801
by: Daniel Vallstrom | last post by:
I'm having problems with inconsistent floating point behavior resulting in e.g. assert( x > 0.0 && putchar('\n') && x == 0.0 ); holding. (Actually, my problem is the dual one where I get...
13
2771
by: Leonardo Francalanci | last post by:
With mysql I know how much space a row will take, based on the datatype of it columns. I also (approximately) know the size of indexes. Is there a way to know that in postgresql? Is there a way...
4
13205
by: thinktwice | last post by:
i have just made a test project :(win32 console) //file : func.h #ifndef _FUNC_H_ #define _FUNC_H_ void func1() { return; };
3
3304
by: KimberlyM | last post by:
This has been driving me crazy. I hope someone can help. The site displays perfectly in FF but all div's do not show in IE. Please help me find the problem! Thanks! Here is my css. ...
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.