I have the a few questions regarding a piece of code I am trying to understand. I have read the manual here. But it does not seem to explain or answer all of the tricks being used here.
Here is the code:
#define SAMPLE_OFFSET1 0
#define SAMPLE_OFFSET2 100
#define SAMPLE_OFFSET1 1000
#define STRINGIFY(s) #s
struct data {
int m1;
int m2;
const uint *m3;
const uint *m4;
};
#define assembly_function(param1, ... param15) \
... body \
... body \
... body \
... body
void testFunction (data* c, uint *const sample) {
int bat, tmp;
__asm__ volatile(
assembly_function("%0", "%q0", "(%4)", "%1", "%w1",
"%2", "%q2", "%3", "%b3",
"%c6(%5)", "%c7(%5)",
STRINGIFY(SAMPLE_OFFSET1),
STRINGIFY(SAMPLE_OFFSET2),
STRINGIFY(SAMPLE_OFFSET3),
"%8")
: "=&r"(bat), "=&r"(c->m1), "=&r"(c->m2), "=&q"(tmp)
: "r"(sample), "r"(c),
"i"(offsetof(data, m3)),
"i"(offsetof(data, m4)),
"1"(c->m1), "2"(c->m2)
: "%rcx", "memory"
);
}
I have wild guesses about the usage of some of the following constraints/options. But I feel its better to confirm from other fellows (or get link to some detailed manual).
- %c in "%c6(%5)" and "%c7(%5)"
- %q in "%q0" and "%q2",
- %b in "%b3"
- %w in "%w1"
- parentheses in "(%4)"
- "i" for two of the input parameters.
- "1" and "2" for two of the input parameters.
Thanks for your help.