I found a few things online using Google, but I still can't seem to make the compiler happy. I even uncovered a bug in the compiler while trying to get this to work. I have tried this a couple of different ways and clang is giving me fits. This is on FreeBSD 9.3.
In the above code snippet, clang wants me to replace the comma with a closing parenthesis on the first line. I am kinda at a loss on how this is supposed to work. I am familiar with x86 assembly, so that's not an issue here.
Here's the second code snippet that I tried:
But, it does not like how I am accessing the structure bn1. I've tried two different ways to see which one works. I was told however that clang may reorder the statements, which is what I definitely do not want.
How do you access a structure in inline asm?
How do you access local variables?
My big problem is stemming from the fact that I have never used inline assembly in C before. I've either used it as a stand alone asm file or inline in Borland Pascal (many moons ago).
Code:
__asm__ ("pushl %%eax",
"pushl %%edx",
"pushf",
"movl (bn1->dat[noparse][i][/noparse]), %%eax",
"xorl %%edx, %%edx",
"divl ($0x0c + bn2 + j)",
"movl %%eax, (q)",
"movl %%edx, (m)",
"popf",
"popl %%edx",
"popl %%eax"
);
In the above code snippet, clang wants me to replace the comma with a closing parenthesis on the first line. I am kinda at a loss on how this is supposed to work. I am familiar with x86 assembly, so that's not an issue here.
Here's the second code snippet that I tried:
Code:
__asm__ (".intel_syntax noprefix");
__asm__ ("pushl %eax");
__asm__ ("pushl %edx");
__asm__ ("pushf");
__asm__ ("movl %eax, (bn1->dat[noparse][i][/noparse])");
__asm__ ("xorl %edx, %edx");
__asm__ ("divl ($0x0c + bn2 + j)");
__asm__ ("movl (q), %eax");
__asm__ ("movl (m), %edx");
__asm__ ("popf");
__asm__ ("popl %edx");
__asm__ ("popl %eax");
But, it does not like how I am accessing the structure bn1. I've tried two different ways to see which one works. I was told however that clang may reorder the statements, which is what I definitely do not want.
How do you access a structure in inline asm?
How do you access local variables?
My big problem is stemming from the fact that I have never used inline assembly in C before. I've either used it as a stand alone asm file or inline in Borland Pascal (many moons ago).