|
Just wirte your assembly code as inline and make the function declaration as naked this will remove all c++ prolog and epilog to a function (like stack checking, parameter checking etc etc). if you do this then you dont have to worry what compier does.
|
|
|
|
|
If there's one thing I learned when I started diving into building my own compiler, it's that modern C and C++ compilers are smart. Very smart.
That said, they aren't perfect, and sometimes they'll focus optimizations on parts of your code that aren't as critical, or they'll refuse to do certain optimizations because it cannot be proven from the language definition that the optimization is safe. And, of course, they can't magically pick a better algorithm for you.
What this means in practical terms is that you shouldn't try to do premature optimizations. Write it in the language of your choice. Benchmark it. Profile it. You might just find that it's fast enough already. If not, you can find the bottlenecks and then break out the assembly.
- Mike, who has wasted entire too much time optimizing for code which wasn't a problem.
|
|
|
|
|
First off do not use .NET managed C++. I would program it in C++ and add assembly where needed. One case in point is if you have to do any float to int calculations do not let the compiler do that. The cpu does rounding by default and the standard states it should be truncated. So the compiler inserts over 100 asm instructions to reverse the rounding process. In a bilinear interpolation algorithm I got a factor of 10 speed up by using asm to do the conversion. Also where possible I would use MMX, and SIMD.
John
|
|
|
|
|
thanks...
that's what i am kinda thinking about: writing the program in C++ under visual c++ 6, and using inline assembly to optimize where necessary for mmx/3dnow/sse. i could do that under .net using intrinsics, but i don't feel much confortable with that...
|
|
|
|
|
.NET is ok as long as you do not use the .NET CLR runtime. I do have one warning though. To use the mmx/3dnow/sse instructions in inline assembly on VC5 or VC6 you need the processor pack. The problem is the processor pack breaks exceptions (try() catch() blocks) in some cases and this could cause your program to crash. This is why I would recommend the VC.NET. It has builtin support for mmx/3dnow/sse.
John
|
|
|
|
|
how do I get the path to what on my system is C:\Program Files?
I'm looking up the value of %PROGRAMFILES% currently but this might not be defined on every system.
<br />
TCHAR szPath[MAX_PATH + 1];<br />
ExpandEnvironmentStrings("%PROGRAMFILES%",szPath,MAX_PATH);<br />
any alternatives? Do I have to lookup some reg key?
Thanks.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - Writing Word addins
Office addin
|
|
|
|
|
Use SHGetFolderPath() to get the location of the folder CSIDL_PROGRAM_FILES (that function is in shfolder.dll which you can redistribute, and it comes with any recent OS and IE version)
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
I use the c function _getcwd to retrieve the current working directory which is almost always the directory the program is running in unless you have your working directory set differently when doing debugs in VC++.
Code4Food
----
"There is no try; only do or do not"
-Yoda
|
|
|
|
|
Code4Food wrote:
"There is no try; only do or do not"
-Yoda
I think that is my all time favorite movie quote...
John
|
|
|
|
|
How can I display international strings? Is there a function like setlocale which I have to invoke for the various subsystems (GDI, USER etc, etc)
|
|
|
|
|
The simpilest way is to use UNICODE. There are articles at codeproject and else where on this subject. Also, if you want to develop international application you should get a copy of "Developing Internation Software for Windows...." [Microsoft Press] (a new revision of this book came out last year).
INTP
|
|
|
|
|
Hi everybody
I'm developing a small application in MFC, where I need one combobox filled with two different kind of strings.
In between these two types I need a double line, like the one in MS Word Font combo box.
I've made my combo box with owner draw fixed and draw one line at the place where I required. But the line doesnt look exactly the same as in MS Word. Also my combo box is a little bigger when compared with normal combo box.
Please help me out to find a better method to develop this combo box.
Thanks in adavance
Luzmu
Luzmu
|
|
|
|
|
hi everybody,
I followed completely the example
http://www.mathworks.com/support/solutions/data/27671.shtml
and tried to learn the idea but I met some linking problem about it.
Linking...
foowrap.obj : error LNK2001: unresolved external symbol _mxCreateDoubleScalar
Debug/test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
test.exe - 2 error(s), 0 warning(s)
what can i do in order to settle the linking errors.
and here is another question,
if i plan to call the matlab function
[features, targets] = improved_DA1(x,[cluster,0.95]);
how can i settle such kind of scenario and calling the [ ] in reference with the website tutorial method,http://www.mathworks.com/support/solutions/data/27671.shtml
thank you for your all helping
vincent sim
|
|
|
|
|
How one can change the shape, i.e. look and feel of the window using MFC code ?
Can you give me an example of making a Round or Elliptical window ?
|
|
|
|
|
|
Hi!
I would like to be notified when a user presses CTRL+A in an Edit control.
I derived the OnKeyDown function, but I received the notification when the user presses CTRL then when he presses A.
How to be sure that the CTRL key has been pressed when I receive the notification when the A key is down?
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
Use GetKeyState within your handler for the A key being pressed.
Brad
|
|
|
|
|
|
Hi,
I would like to design a Visual application that can display external input information from the sound card.
I only really have experience of C and was wondering if there are any tutorials to help design a sound application?
Could someone also recommend a good, free C++ compiler / programming software.
|
|
|
|
|
|
I am sending a file through a WLAN card and from one pc to another. How can I save a file that have been received in the receiver PC? I don't know actually how to use VC++ to save a file in a computer either...
semnanian
|
|
|
|
|
wrong group
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
One solution is CreateFile().
Kuphryn
|
|
|
|
|
Hello,
I assume that the client pc has to do the saving by itself. When you are using MFC try CFile.
If you(host) have to save the file on the client pc, try some ftp.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
This is really disturbing as I only have this problem with some themes (including the standard themes).
When I draw text using DrawThemeText and theme data for "Button , then the font is mismatched sometimes. Using the theme "Watercolor", the font is just like it should be. But with standard XP themes for instance, the font is System. You know.. the butt ugly font.
What am I missing here!?
I am using the WTL theme classes, and I did try using the raw API. In both cases I get the same result. If I do this:
hTheme = OpenThemeData(m_hWnd, L"Button");
DrawThemeText(hTheme, hdc, BP_PUSHBUTTON, BPS_NORMAL, CT2CW(szText), -1,
DT_VCENTER | DT_CENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS, 0, &rcClient); I end up with an ugly text drawn with the System font.
Help. Please?
--
"We shall crush you down to the point,
where there is no coming back,
things will happen to you from
which you could not recover if you
lived a thousand years, a thousand years."
|
|
|
|