Move test in a specific folder
This commit is contained in:
25
example/naked.c
Normal file
25
example/naked.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// No function prologue/epilogue - raw assembly only
|
||||
__attribute__((naked))
|
||||
void my_naked_function()
|
||||
{
|
||||
__asm__ volatile (
|
||||
"movl $42, %eax\n\t"
|
||||
"ret"
|
||||
);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int result;
|
||||
__asm__ volatile (
|
||||
"call my_naked_function\n\t"
|
||||
"movl %%eax, %0\n\t"
|
||||
: "=r"(result)
|
||||
:
|
||||
: "%eax"
|
||||
);
|
||||
printf("Result from naked function: %d\n", result);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user