Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8197349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:43:17+00:00 2026-06-07T05:43:17+00:00

I am trying to learn ASM, and want to try a few things combined

  • 0

I am trying to learn ASM, and want to try a few things combined with C++. The ASM part is done in a naked function. But whenever I call the function (empty) the application crashes in the next function. What should I do in the naked function to make it work, do I need to pop esp or something? An example could be helpfull.

_declspec(naked) void asmfunc()
{
    _asm
    {
    }
}

int _tmain(int argc, _TCHAR* argv[])
{
    i = 1;

    asmfunc();

    cout << i << endl; // <-- crash
    system("pause");

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:43:18+00:00Added an answer on June 7, 2026 at 5:43 am

    Naked function will not contain any compiler-generated prologue and epilogue code. That applies to the implicit return statement at the end of the function as well.

    That means that the function you declared has no ret instruction at the end. Once the control is transferred to asmfunc, it never returns. The function continues to execute whatever code exists at that location until it hits something that makes it crash.

    Basically, your original implementation of asmfunc works as a label somewhere in the middle of the program code. And when you call your function, you are essentially doing a goto asmfunc, i.e. you transfer control somewhere without any hope of return.

    For this reason, a minimal naked function should look as

    _declspec(naked) void asmfunc()
    {
        _asm
        {
          ret
        }
    }
    

    It is your responsibility to place ret instructions into a naked function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to learn F# but got confused when trying to distinguish between fold and
I'm trying to learn the basics asm on linux and I can't find a
Trying to learn R and am stuck on an autocorrelation example. I want to
trying to learn and practice arrays but I have a problem with this small
I trying to learn OOP and I've made this class class boo{ function boo(&another_class,
I am trying to learn a few different methods of calling functions by address.
I am somewhat new to jQuery but have been having fun trying learn about
Trying to learn Haskell. I am trying to write a simple function to remove
I'm a total newbie with socks5, but I'm trying learn by creating a socks5
Trying to learn shaders and get a dead simple directional light source working but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.