如何通过汇编器在Visual Studio中输出信息

我尝试使用汇编程序,当我调用int 0x80时,我的程序崩溃了。如果我想在C ++代码中通过汇编器在控制台中输出一些信息,该怎么办?

#include <iostream>

int main()
{
    char *msg = "Hello";

    __asm
    {      
        mov eax,4; 
        mov ebx,1;
        mov ecx,msg; 
        mov edx,5; 
        //int 0x80;
    }
    system("pause");
    return 0;
}
daming_110 回答:如何通过汇编器在Visual Studio中输出信息

我发现一些有趣的方法可以使用Visual Studio C ++在Inline ASM中输出Hello world。

char* hi = "Hello World\n";
char* text = "%s";
__asm
{
    mov eax,hi;             // load C pointer variable from memory
    push eax;                // function args on the stack with rightmost highest
    mov eax,text;
    push eax;
    call DWORD ptr printf;    // indirect call to DLL function
    pop eax;                  // clean up the stack
    pop eax;                  // with these 2 dummy pops
}

本文对此进行了详细介绍:http://rodrigosavage.blogspot.com/2010/07/hello-world-with-inline-asm.html?m=1

本文链接:https://www.f2er.com/3168683.html

大家都在问