0
#include <iostream>
#include <Windows.h>

using namespace std;


int main() {

    const char* message = ("hi");

    __asm {

    print:
        push ebp;
        mov ebp, esp;

        mov ebx, [ebp + 8]; <- First argument
        push ebx;
        call printf;

        mov esp, ebp;
        pop ebp;
    ret;

        mov eax, message;
        push eax;

        call print;
    };


    std::cin.get();
    return (0);
};

I'm using an inline assembler obviously. I don't understand why this is an error, I've tried using leave instead of destroying the stack frame manually, no luck. I don't understand where I went wrong here.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • Are you using Visual Studio, and if so, have you tried [this](https://stackoverflow.com/questions/47933932/visual-studio-2017-debug-error-frame-not-in-module)? – dddJewelsbbb Dec 16 '19 at 01:38
  • 3
    I don't know why you want to put a function in inline assembly and call it that way, however if you really want to do that youl will have to `jmp` over the function to the `mov eax, message`. You will also have to balance the stack by adding 4 to ESP after `call print` (or just use `pop eax` after the `call print`. – Michael Petch Dec 16 '19 at 01:50

0 Answers0