Since I’m very new to GCC, I’m facing a problem in inline assembly code. The problem is that I’m not able to figure out how to copy the contents of a C variable (which is of type UINT32) into the register eax. I have tried the below code:
__asm__
(
// If the LSB of src is a 0, use ~src. Otherwise, use src.
"mov $src1, %eax;"
"and $1,%eax;"
"dec %eax;"
"xor $src2,%eax;"
// Find the number of zeros before the most significant one.
"mov $0x3F,%ecx;"
"bsr %eax, %eax;"
"cmove %ecx, %eax;"
"xor $0x1F,%eax;"
);
However mov $src1, %eax; doesn’t work.
Could someone suggest a solution to this?
I guess what you are looking for is extended assembly e.g.:
In the example above, we made the value of
bequal to that ofausing assembly instructions andeaxregister:Please see the inline comments.
note:
A good read about inline assembly in GCC environment.