Advertisement

ASM functions in VC++

Started by July 22, 2000 01:47 PM
3 comments, last by ranxact 24 years, 5 months ago
Hello all, I need to write a function entirely in ASM. int function() { <- but there are ASM instructions here... _asm{ ASM instuctions... } } the function calling it needs to have certain regesters retained, however, I call it often enough to not want to push them and pop them everytime i call it. (i don''t need to use them in the function) would making the function inline work? maybe i should use a macro? but i call it alot...
RanXact@yahoo.com
Yes, preserving the registers that are being used is happening before your ASM statement that you can''t really see, so what you need to do is make your function entirely in ASM, and then compile the code to an OBJ file, and link it to your VC program. declare the function as a extern "C" void MyFunction(int blah);

etc...

Hope this helps!

------------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..
Advertisement
You can declare the function as ''naked'' (see MSDN library for details). That keyword does exactly what you want: It tells the
compiler not to write its own into/extro code and gives you the full control. However you will have to watch for destroyed register contents and correct stack handling.
The ''naked'' keyword is intended to be used esp. for driver development etc.

HTH,
Alex



Alexander Stockinger
Programmer
Alexander Stockinger
Programmer
wow, i didn''t know about naked!
it''s perfect for something that gets called thousands of times a second and needs all the speed it can get


DaJudge you are DaMan... Thanx for the help. ''NaKed''... i would have never tried that on my own... Although i think i will remember it

RanXacT

(and Gladiator, that was my alternative, but i am actually switching from MASM to VC++ for the better Debugging ....)
RanXact@yahoo.com

This topic is closed to new replies.

Advertisement