Mixing C and Assembly files

后端 未结 4 947
囚心锁ツ
囚心锁ツ 2020-12-16 23:24

I want to use a naked function in my C++ program using g++. Unfortunately g++, unlike VC++, does not support naked functions and the only way to manage this is to write your

4条回答
  •  囚心锁ツ
    2020-12-17 00:12

    I just want to add one thing to previous post. Imagine you want a function, that accept arguments: (something like

    int add(int,int);

    prototype)

    segment .text
    global add
    
       add:
       enter 0,0
       mov eax,[ebp+8]  ; first argument
       mov ebx,[ebp+12]  ; second argument
       add eax,ebx
       leave
       ret
    

提交回复
热议问题