Click here to Skip to main content
15,888,271 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Simply,I want to know when and how to integrate appropriate assembly instructions within C++(I am using Visual C++) program boundary/enviornment to gain more efficient and effectiveness via optimization(Compile-time & Run-time).
I've already referred "Text Book - "Visual C++ Optimization With Assembly Code",but some of its topics were designed for Experienced People.Please provide simple guidelines (Why do we want to use them properly,when to use them and how?) with relevant examples to explain how to use assembly/intrinsic instructions within C++ for specific platform or platform independently.
Thank in advance.
Posted
Comments
KarstenK 16-Jan-15 2:56am    
Todays compiler and linker are fine, so assembler code isnt often needed. My opinion is, that today the software design, usability and stability (DAU and fool proof) is the focus of software development.
Buddhi Chaturanga 17-Jan-15 14:03pm    
There are some particular cases in optimization;that compiler cannot make a decision or produce.

This can't be answer in a couple of lines. Better find and read more books, One book is usually not enough.

For basic please see below article

Using Inline Assembly in C/C++[^]
 
Share this answer
 
Comments
Buddhi Chaturanga 17-Jan-15 14:04pm    
Thank you for the reply,really appreciated.The link was really helpful.
This cant' be answered in short. When providing all requested information (why, when, how, examples, platform / compiler support) the answer can be posted as article here.

Using inline assembly and intrinsics is an advanced topic. When not having experiences so far you must put some time and effort into reading. This includes knowledge of the used processor and its assembly language.

Why
To reduce execution time of time critical code or when the problem can't be solved otherwise (e.g. using specific intrinsics).

When
Only if really necessary.

How
This depends on the used compiler and platform (e.g. inline assembly is not supported by the MS compiler when building 64-bit applications). See the compiler documentation.
 
Share this answer
 
Comments
Buddhi Chaturanga 17-Jan-15 14:07pm    
Thank you Joch' very much.Your last point related to "How" topic was really helpful.
Why MS compiler doesn't support for inline assembly on x86-64 builds?
Jochen Arndt 18-Jan-15 5:30am    
You are welcome.

MS did not explained why (at least I don't know about).
They probably did not support it because the compiler can not perform all optimizations on the C/C++ code parts for functions using inline assembly.
If you are a unexperienced then it doesn't make much sense such kind of advanced optimization: you better fine tune your algorithms (as well compiler optimization settings). If you really need such kind of optimization then you probably have to gain some experience (unfortunately "there is not a Royal Road to geometry").
 
Share this answer
 
Comments
Buddhi Chaturanga 17-Jan-15 14:04pm    
Hahaha agree,, Thank you for the reply :D
CPallini 17-Jan-15 16:04pm    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900