language: C (gcc-4.7.2)
date: 887 days 9 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdlib.h>
 
static const char* printtext="first element=%d\n";
 
extern void do_stuff_in_asm(int* array, int len);
void dummy(int* array, int len)
{
    __asm__ __volatile__(
        "do_stuff_in_asm:\n\t"
        "pushl %%ebp\n\t"
        "movl %%esp, %%ebp\n\t"
        "movl 8(%%ebp), %%eax\n\t"
        "movl 12(%%ebp), %%ecx\n\t"
        "movl $0, %%edi\n\t"
        "movl (%%eax,%%edi,4), %%edx\n\t"
        "pushl %%edx\n\t"
        "pushl %0\n\t"
        "call printf\n\t"
        "addl $8, %%esp\n"
        "popl %%ebp\n\t"
        "ret" : : "m" (printtext));
}
 
int main()
{
    int *array, n;
    n = 10;
    array = malloc (n * sizeof(int));
    array[0] = 42;
    do_stuff_in_asm(array, n);
    return 0;
}