Creating a C function without compiler generated prologue/epilogue & RET instruction?

前端 未结 3 1484
野性不改
野性不改 2020-12-02 00:19

Consider this function:

void foo(){
    //do something
}

In assembly it would look something like this (not accurate):

push         


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 00:57

    I am guessing you want the syntax of having a function without having the C compiler do anything. You can do this by linking to your assembly function, (and then it will need to of course copy the correct things onto the stack).

    Your assembly routines just need an entry point for the C compiler to call, for instance:

    The assembly portion would contain the following header:

    global my_function 
    my_function:
    push r1
    push r2
    ; Code 
    ret
    

    corresponding to:

    void  my_function ( int arg1, char arg2 ); 
    

提交回复
热议问题